A Google Rank Checker. Enter a search term and URL and the script will determine the position of the URL in the Google search results for that search term.
This script uses the WebRecorder IEAuto.DLL library to manipulate Google in Internet Explorer and parse the search results. It demonstrates how WebRecorder can be used to automate web pages and analyse the source.
Code: Select all
/*
Google Rank Checker
Copyright 2008 MJT Net Ltd
Updat 9th August 2008: Updated for recent changes to Google html
*/
Dialog>Dialog1
Caption=Google Rank Checker
Width=346
Height=226
Top=CENTER
Left=CENTER
Max=0
Min=0
Close=1
Resize=0
Label=Search Term:,8,16,true
Label=URL:,8,48,true
Label=Number of Pages to Scan:,8,88,true
Edit=txtSearch,96,16,225,
Edit=txtURL,96,48,225,
Edit=txtNumPages,144,80,33,5
Button=OK,160,120,75,25,4
Button=Cancel,248,120,75,25,2
CheckBox=msCheckBox1,Hide IE,256,80,65,False
Button=Built with Macro Scheduler,8,160,321,25,0
Default=OK
EndDialog>Dialog1
Label>start
Show>Dialog1,r
If>r=20
ExecuteFile>http://www.mjtnet.com/
Goto>end_script
Endif
If>r=2,end_script
If>{(%Dialog1.txtSearch%="") OR (%Dialog1.txtURL%="")}
MessageModal>Please enter a search term and URL
Goto>start
Endif
Let>PagesToScan=Dialog1.txtNumPages
Let>Keywords=Dialog1.txtSearch
Let>URLToFind=Dialog1.txtURL
LibLoad>IEAuto.dll,hIE
If>hIE=0
MessageModal>Could not load IEAuto.dll, make sure it is in the path or edit the LibLoad line.
Goto>end_script
EndIf
//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
LibFunc>hIE,CreateIE,IE[0],0
if>Dialog1.msCheckBox1=True
LibFunc>hIE,ShowIE,r,IE[0],0
Endif
//Go to Google.com
LibFunc>hIE,Navigate,r,%IE[0]%,http://www.google.com/advanced_search?hl=en
LibFunc>hIE,WaitIE,r,%IE[0]%
Wait>delay
//Enter a search term
Let>FrameName={""}
Let>FormName={"f"}
Let>FieldName={"as_q"}
Let>FieldValue=Keywords
LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0
//Set to 10 results per page
Let>FrameName={""}
Let>FormName={"f"}
Let>FieldName={"num"}
Let>FieldValue={"10 Results"}
LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0
//Set to Englisg
Let>FrameName={""}
Let>FormName={"f"}
Let>FieldName={"lr"}
Let>FieldValue={"English"}
LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,submit
LibFunc>hIE,WaitIE,r,%IE[0]%
Wait>delay
//Scan through all texts looking for results ....
Let>rank=0
Let>IsFound=0
Let>PagesDone=0
Label>ScanPage
Let>p=0
Label>scan
Let>P%p%_SIZE=4098
Let>P%p%=DUMMY
LibFunc>hIE,ExtractTag,r,%IE[0]%,,SPAN,p,0,P%p%
MidStr>r_6,1,r,this
Let>rank=rank+1
//Diagnostic showing results as scanned
//MessageModal>Pos %rank%: %this%
Pos>URLToFind,this,1,IsFound
If>IsFound>0
MessageModal>Found %URLToFind% in Position: %rank%
Goto>Finish
Endif
Let>p=p+1
If>p<10,scan
Label>end_scan
//Click the Next button
Let>FrameName={""}
Let>FormName={"f"}
Let>TagValue={"Next"}
LibFunc>hIE,ClickTag,r,%IE[0]%,str:FrameName,str:FormName,A,TEXT,str:TagValue
LibFunc>hIE,WaitIE,r,%IE[0]%
Wait>delay
Let>PagesDone=PagesDone+1
//Loop back and do next page if required
If>PagesDone<PagesToScan,ScanPage
Label>Finish
//Comment next line out if you don't want IE to close
LibFunc>hIE,KillIE,r,IE[0]
If>IsFound=0
Ask>%URLToFind% Not Found in Search Results. Try again?,restart
If>restart=YES
Goto>start
Endif
Endif
LibFree>hIE
Label>end_script
If you do not have Macro Scheduler you can download a compiled version of this script here:
http://www.mjtnet.com/software/GoogleRankCheck.zip
This includes an evaluation version of the IEAuto.DLL library.
Updated: August 2008 for recent changes to Google HTML