News for hackers. Stuff that matters.

Ask HN: Does anyone have experience scraping dynamic content?

http://www.nfl.com/scores

For example, for this URL, there is a section on the right for "Big Play Highlights" and the first one listed is "L.Brown 7-yard TD pass from..."

It looks like this data is being loaded via some kind of AJAX call. Do you have any ideas on how I can scrape this stream of highlights data? I've never tried to scrape any dynamic content in the past.

Ideas?

( 4 comments | 3 points | on HN )
Re:Ask HN: Does anyone have experience scraping dynamic cont... by AznHisoka on Monday August 20, 2012 @09:31PM (#4410713)
PhantomJS/CasperJS is what I've used for my current scraping projects. They're headless browsers and imitate a browser session. Just specify a fake user agent like Mozilla, and you're good to go.
Re:Ask HN: Does anyone have experience scraping dynamic cont... by bartonfink on Friday August 17, 2012 @06:24PM (#4399120)
You MAY be able to do this with Selenium, although I've never used Selenium to scrape streaming requests. It's going to depend quite a bit on how the page is structured.

I have used Selenium to scrape dynamic content before by waiting for new DOM elements to be populated by AJAX, so I know this sort of thing is possible in a way you couldn't do with wget.

Re:Ask HN: Does anyone have experience scraping dynamic cont... by jfaucett on Friday August 17, 2012 @06:30PM (#4399143)
yea, just look at the http headers, here's the call: http://www.nfl.com/liveupdate/scores/bigPlayVideos.json?rand...

just make your own tstamp for random

Re:Ask HN: Does anyone have experience scraping dynamic cont... by bonsai on Tuesday August 21, 2012 @03:17AM (#4411521)
HtmlUnit has very good support for javascript. http://htmlunit.sourceforge.net/