scrape

scraping xml/javascript table with R [closed]

孤街醉人 提交于 2019-12-04 16:07:32
I want to scrape a table like this http://www.oddsportal.com//hockey/usa/nhl/carolina-hurricanes-ottawa-senators-80YZhBGC/ I'd want to scrape the bookmakers and the odds. The problem is I don't know what kind of a table that is nor how to scrape it. These threads might be able to help me ( Scraping javascript with R or What type of HTML table is this and what type of webscraping techniques can you use? ) but I'd appreciate if someone could point me in the right direction or better yet give instructions here. So what kind of a table is that odds table, is it possible to scrape it with R and if

Node Jsdom Scrape Google's Reverse Image Search

荒凉一梦 提交于 2019-12-04 15:09:25
问题 I want to programatically find a list of URLs for similar images given an image URL. I can't find any free image search APIs so I'm trying to do this by scraping Google's Search by Image. If I have an image URL, say http://i.imgur.com/oLmwq.png, then navigating to https://www.google.com/searchbyimage?&image_url=http://i.imgur.com/oLmwq.png gives related images and info. How do I get jsdom.env to produce the HTML your browser gets from the above URL? Here's what I've tried ( CoffeeScript ):

Using SoupStrainer to parse selectively

被刻印的时光 ゝ 提交于 2019-12-04 09:38:59
Im trying to parse a list of video game titles from a shopping site. however as the item list is all stored inside a tag . This section of the documentation supposedly explains how to parse only part of the document but i cant work it out. my code: from BeautifulSoup import BeautifulSoup import urllib import re url = "Some Shopping Site" html = urllib.urlopen(url).read() soup = BeautifulSoup(html) for a in soup.findAll('a',{'title':re.compile('.+') }): print a.string at present is prints the string inside any tag that has a not empty title reference. but it is also priting the items in the

download list of images from urls

自闭症网瘾萝莉.ら 提交于 2019-12-04 05:43:10
问题 I need to find (preferably) or build an app for a lot of images. Each image has a distinct URL. There are many thousands, so doing it manually is a huge effort. The list is currently in an csv file. (It is essentially a list of products, each with identifying info (name, brand, barcode, etc) and a link to a product image. I'd like to loop through the list, and download each image file. Ideally I'd like to rename each one - something like barcode.jpg. I've looked at a number of image scrapers,

Python - save requests or BeautifulSoup object locally

走远了吗. 提交于 2019-12-04 03:43:56
问题 I have some code that is quite long, so it takes a long time to run. I want to simply save either the requests object (in this case "name") or the BeautifulSoup object (in this case "soup") locally so that next time I can save time. Here is the code: from bs4 import BeautifulSoup import requests url = 'SOMEURL' name = requests.get(url) soup = BeautifulSoup(name.content) 回答1: Since name.content is just HTML , you can just dump this to a file and read it back later. Usually the bottleneck is

Get data between two tags in Python

允我心安 提交于 2019-12-03 21:49:32
<h3> <a href="article.jsp?tp=&arnumber=16"> Granular computing based <span class="snippet">data</span> <span class="snippet">mining</span> in the views of rough set and fuzzy set </a> </h3> Using Python I want to get the values from the anchor tag which should be Granular computing based data mining in the views of rough set and fuzzy set I tried using lxml parser = etree.HTMLParser() tree = etree.parse(StringIO.StringIO(html), parser) xpath1 = "//h3/a/child::text() | //h3/a/span/child::text()" rawResponse = tree.xpath(xpath1) print rawResponse and getting the following output ['\r\n\t\t','\r

How to download images from BeautifulSoup?

余生长醉 提交于 2019-12-03 15:20:30
Image http://i.imgur.com/OigSBjF.png import requests from bs4 import BeautifulSoup r = requests.get("xxxxxxxxx") soup = BeautifulSoup(r.content) for link in links: if "http" in link.get('src'): print link.get('src') I get the printed URL but don't know how to work with it. Padraic Cunningham You need to download and write to disk: import requests from os.path import basename r = requests.get("xxx") soup = BeautifulSoup(r.content) for link in links: if "http" in link.get('src'): lnk = link.get('src') with open(basename(lnk), "wb") as f: f.write(requests.get(lnk).content) You can also use a

Node Jsdom Scrape Google's Reverse Image Search

[亡魂溺海] 提交于 2019-12-03 08:55:00
I want to programatically find a list of URLs for similar images given an image URL. I can't find any free image search APIs so I'm trying to do this by scraping Google's Search by Image . If I have an image URL, say http://i.imgur.com/oLmwq.png , then navigating to https://www.google.com/searchbyimage?&image_url=http://i.imgur.com/oLmwq.png gives related images and info. How do I get jsdom.env to produce the HTML your browser gets from the above URL? Here's what I've tried ( CoffeeScript ): jsdom = require 'jsdom' url = 'https://www.google.com/searchbyimage?&image_url=http://i.imgur.com/oLmwq

Reading data from PDF files into R

你离开我真会死。 提交于 2019-12-03 00:46:00
问题 Is that even possible!?! I have a bunch of legacy reports that I need to import into a database. However, they're all in pdf format. Are there any R packages that can read pdf? Or should I leave that to a command line tool? The reports were made in excel and then pdfed, so they have regular structure, but many blank "cells". 回答1: Just a warning to others who may be hoping to extract data: PDF is a container, not a format. If the original document does not contain actual text, as opposed to

BeautifulSoup to scrape street address

左心房为你撑大大i 提交于 2019-12-02 22:34:22
问题 I am using the code at the far bottom to get weblink , and the Masjid name . however I would like to also get denomination and street address . please help I am stuck. Currently I am getting the following Weblink: <div class="subtitleLink"><a href="http://www.salatomatic.com/d/Tempe+5313+Masjid-Al-Hijrah"> and Masjid name <b>Masjid Al-Hijrah</b> But would like to get the below; Denomination <b>Denomination:</b> Sunni (Traditional) and street address <br>45 Station Street (Sydney)   The below