Scraping Google News
Scrape Google News search results to get at the latest from thousands of aggregated news sources.
Since Google added thousands of sources to its Google News [Hack #32] search engine, it’s become an excellent source for any researcher. However, because you can’t access Google News through the Google API, you’ll have to scrape your results from the HTML of a Google News results page. This hack does just that, gathering up results into a comma-delimited file suitable for loading into a spreadsheet or database. For each news story, it extracts the title, URL, source (i.e., news agency), publication date or age of the news item, and an excerpted description.
Because Google’s Terms of Service prohibits the automated access of their search engines except through the Google API, this hack does not actually connect to Google. Instead, it works on a page of results that you’ve saved from a Google News search you’ve run yourself. Simply save the results page as HTML source using your browser’s File → Save As... command.
Make sure the results are listed by date instead of relevance. When
results are listed by relevance some of the descriptions are missing,
because similar stories are clumped together. You can sort results by
date by choosing the “Sort By Date”
link on the results page or by adding
&scoring=d to the end of the results URL. Also
make sure you’re getting the maximum number of
results by adding &num=100 to the end of the
results URL. For example, Figure 4-2 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access