Extract Number of Google Search Results

Information related to the use of iMacros for Web Scraping, Data Mining and creating Mashups.

Moderator: iMacros Moderators

Extract Number of Google Search Results

by Tech Support on Fri Jan 09, 2009 7:16 am

How to extract the number of search results in Google.

Here is the solution:

Method A: Use the comma to identify the number we need. This macro would fail if we have less then 1000 results.
Code: Select all
URL GOTO=http://www.google.com/     
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT=solar<SP>cells
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG 
TAG POS=1 TYPE=B ATTR=TXT:*,* EXTRACT=TXT 


Method B (recommended): Use relative extraction with the word "Results" as anchor:
google information retrieval.png
How to extract information from Google
google information retrieval.png (49.53 KIB) Viewed 13657 times

Code: Select all
URL GOTO=http://www.google.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT=solar<SP>cells
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG     
TAG POS=1 TYPE=P ATTR=TXT:*Results*
TAG POS=R3 TYPE=B ATTR=TXT:* EXTRACT=TXT


Further Reading:

(1) Web Scraping (General information)

(2) Extract with relative Positioning

Note: In this case we do not recommend to use simply a specific POS statement as suggested by the extraction wizard:
Code: Select all
TAG POS=5 TYPE=B ATTR=TXT:* EXTRACT=TXT 
This works, but as soon as there is one more bold word before our number, the TAG...EXTRACT command will pick up the wrong content.
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

Return to How-To's and Examples for Web Scraping

Who is online

Users browsing this forum: No registered users and 1 guest

-->