Sunday, April 10, 2011
Monday, April 4, 2011
Web Scraping with RapidMiner and XPath
In this video I show how to load 500 html files from a previous web crawl, loop through each of them, and use XPath to grab values from each page, and put them in a data table for later analysis.
Part 2: Web Crawling with RapidMiner
Web Crawling with RapidMiner
Here is part 2 of my series of videos on web crawling with RapidMiner. In this video I show how to crawl about 500 pages from a site, and discuss user agents, crawling rules, and robot exclusion files.
Part 2: Web Crawling with RapidMiner
Sunday, April 3, 2011
More X-Path Goodness
Got a RapidMiner crawling/scraping video coming up, but for now, here are some more X-Path ideas to play with:
//*
return all nodes
//*[contains(., 'Search Text')]
return all nodes that contain Search Text in their content. Case sensitive search.
//div[@id='div1']/following-sibling::*
return the next sibling of a specific node (not sure if this works in RapidMiner)
//div[@id='div1']/../
return the parent node of a specific node
in RapidMiner, precede all nodes with "h:", example: //h:div[@class='abc']/h:a
//*
return all nodes
//*[contains(., 'Search Text')]
return all nodes that contain Search Text in their content. Case sensitive search.
//div[@id='div1']/following-sibling::*
return the next sibling of a specific node (not sure if this works in RapidMiner)
//div[@id='div1']/../
return the parent node of a specific node
in RapidMiner, precede all nodes with "h:", example: //h:div[@class='abc']/h:a
Sunday, February 27, 2011
Web scraping with Google Spreadsheets and XPath
This is part one of a series of video tutorials on web scraping and web crawling.
In this first video, I show how to grab parts of a web page (scraping) using Google Docs Spreadsheets and XPath.
Google Spreadsheets has a nice function called importXML which will read in a web page. You can then apply an XPath to that page, to grab various parts of it, such as one particular value, or all of the hyperlinks. This is a convenient method, as your data will be in a format that is easily downloadable in Excel.
Watch the video here:
Part B of the video is here (sorry about the crap sound, working on it):
Useful XPaths:
//a
grabs all the anchors (hyperlinks) in a document
//a/@href
grabs all the URLs in hyperlinks in a document
//div[starts-with(@class, 'left')]
grabs all the div elements whose css class start with 'left'
//input[@type='text']/..
grabs the parent element of all input text elements
count(//p)
returns the number of paragraph elements in a page
//a[contains(@href, 'craigslist')]/@href
find all the hyperlinks that contain the word 'craigslist'
//blockquote/p[not(@align='center')]
find all the paragraphs that do NOT have center alignment
You can read more about XPath here:
https://developer.mozilla.org/en/XPath/Functions
and here:
http://www.w3schools.com/XPath/xpath_syntax.asp
Part 1: Web scraping with Google Spreadsheets and XPath
Part 2: Web Crawling with RapidMiner
Part 3: Web Scraping with RapidMiner and Xpath
Part 4: Web Scraping AJAX Pages
In this first video, I show how to grab parts of a web page (scraping) using Google Docs Spreadsheets and XPath.
Google Spreadsheets has a nice function called importXML which will read in a web page. You can then apply an XPath to that page, to grab various parts of it, such as one particular value, or all of the hyperlinks. This is a convenient method, as your data will be in a format that is easily downloadable in Excel.
Watch the video here:
Part B of the video is here (sorry about the crap sound, working on it):
Useful XPaths:
//a
grabs all the anchors (hyperlinks) in a document
//a/@href
grabs all the URLs in hyperlinks in a document
//div[starts-with(@class, 'left')]
grabs all the div elements whose css class start with 'left'
//input[@type='text']/..
grabs the parent element of all input text elements
count(//p)
returns the number of paragraph elements in a page
//a[contains(@href, 'craigslist')]/@href
find all the hyperlinks that contain the word 'craigslist'
//blockquote/p[not(@align='center')]
find all the paragraphs that do NOT have center alignment
You can read more about XPath here:
https://developer.mozilla.org/en/XPath/Functions
and here:
http://www.w3schools.com/XPath/xpath_syntax.asp
Part 1: Web scraping with Google Spreadsheets and XPath
Part 2: Web Crawling with RapidMiner
Part 3: Web Scraping with RapidMiner and Xpath
Part 4: Web Scraping AJAX Pages
Friday, January 7, 2011
A Data Explosion Remakes Retailing
From the New York Times:
http://www.nytimes.com/2010/01/03/business/03unboxed.html
"Retailing is emerging as a real-world incubator for testing how computer firepower and smart software can be applied to social science — in this case, how variables like household economics and human behavior affect shopping."
http://www.nytimes.com/2010/01/03/business/03unboxed.html
Monday, January 3, 2011
Computers That Trade on the News
I missed this one around Christmas time...must have been the drive up to Prince George.
In the NY Times:
In the NY Times:
The number-crunchers on Wall Street are starting to crunch something else: the news.More...
Math-loving traders are using powerful computers to speed-read news reports, editorials, company Web sites, blog posts and even Twitter messages — and then letting the machines decide what it all means for the markets.
Subscribe to:
Posts (Atom)