Jump to content


Help Auto Google Advance Search

  • Please log in to reply
2 replies to this topic

#1 MaoMao



  • Active Members
  • 41 posts

Posted 28 November 2011 - 11:08 AM

Please help for Autoit Google Advance Search
Trying to perform Advance search in Google Advance search:

How to do multiple entry to perform a list of search objects (Firefox, Chrome, Opera,,,,) in different sites i.e. www.google.com or www.yahoo.com

How to get multiple result in th site to a file.

Plain Text         
#include <File.au3> #include <String.au3> #include <Array.au3> #include <IE.au3> #include <Excel.au3> $ROW = 1 $COL = 1 $file = FileOpen(@WorkingDir&"\LogNames.txt", 0) Local $oExcel = _ExcelBookNew() ;Create new book, make it visible ; Read in lines of text until the EOF is reached While 1 $LogLine = FileReadLine($file) If @error = -1 Then ExitLoop $ROW += 1   $LogCode = StringMid ($LogLine, 1, 20); Extract LogCode $oIE = _IECreate ("http://www.google.com/advanced_search", 0) $oForm = _IEFormGetObjByName ($oIE, "mainform")   $oText = _IEFormElementGetObjByName ($oForm, "this exact wording or phrase")   _IEFormElementSetValue($oText, $LogCode)   $oText2 = _IEFormElementGetObjByName ($oForm, "Search within a site or domain")   _IEFormElementSetValue($oText2, "www.google.com") $netinfo = _IEFormSubmit ($oForm) $inet = InetRead($netinfo) $string = BinaryToString($inet) $space_replace = StringReplace($string,' ','') $string_Between_Data = _StringBetween($space_replace, 'id=resultStats>About', 'results<nobr>') ; _ArrayDisplay($$string_Between_Data, 'Default Search') $string_Between_Percent = _StringBetween($space_replace, 'results<nobr>(', 'seconds)&nbsp') $string_Between_Result = _StringBetween($space_replace, 'id=resultStats>About', 'results<nobr>') ; How to extract a paragraph? ; _ArrayDisplay($$string_Between_Data, 'Default Search') MsgBox(0,'',$string_Between_Data[0]) ;wRITE TO EXCEL FILE ;Declare the Array Local $aArray[$ROW][2] = [[$LogCode, $string_Between_Data]] Local $aArray[$ROW][3] = [[$LogCode, $string_Between_Percent]] Local $aArray[$ROW][3] = [[$LogCode, $string_Between_Result]] _ExcelWriteSheetFromArray($oExcel, $aArray, $ROW, 1, 0, 0) ;0-Base Array parameters Wend; end of While SoundPlay("C:\Windows\media\chimes.wav",1) MsgBox(4096,"Done!","All Log data files have been created!") MsgBox(0, "Exiting", "Press OK to Save File and Exit") _ExcelBookSaveAs($oExcel, @TempDir & "\EXCELTemp.xls", "xls", 0, 1) _ExcelBookClose($oExcel) ; Separate Text file LogNames.txt ;  LogNames.txt ; Firefox ; Chrome ; Internet Explorer ; Safari ; Opera

Testing code not working well. Please help.
Expected ResultBookTraget.xls

Attached Thumbnails

  • Simple.jpg

Edited by MaoMao, 28 November 2011 - 11:17 AM.

#2 bogQ


    For me, it’s simple - it’s a way of life.

  • Active Members
  • PipPipPipPipPipPip
  • 1,902 posts

Posted 08 December 2011 - 08:50 PM

lets answer your first question
#include <IE.au3> $oIE = _IECreate("<a href='http://www.google.com/search?q=chrome+opera' class='bbc_url' title='External link' rel='nofollow external'>http://www.google.com/search?q=chrome+opera"</a>) $oIE = _IECreate("<a href='http://search.yahoo.com/search?p=chrome+opera' class='bbc_url' title='External link' rel='nofollow external'>http://search.yahoo.com/search?p=chrome+opera"</a>)

as for advanced search i don't see where did you finde name of form "mainform" on that page? form name is probably "f" aldo i don't know if its the correct form because i got lost on line 18 of source viewer :D

so if you need advanced search lets at least play with it like this

#include <IE.au3> $oIE = _IECreate("<a href='http://www.google.com/advanced_search' class='bbc_url' title='External link' rel='nofollow external'>http://www.google.com/advanced_search"</a>) $oForm = _IEFormGetCollection ($oIE, 0) $oQuery = _IEFormElementGetCollection ($oForm, 1) _IEFormElementSetValue ($oQuery, "TESTING"&1) $oQuery = _IEFormElementGetCollection ($oForm, 2) _IEFormElementSetValue ($oQuery, "TESTING"&2) $oQuery = _IEFormElementGetCollection ($oForm, 3) _IEFormElementSetValue ($oQuery, "TESTING"&3) $oQuery = _IEFormElementGetCollection ($oForm, 4) _IEFormElementSetValue ($oQuery, "TESTING"&4) $oQuery = _IEFormElementGetCollection ($oForm, 5) _IEFormElementSetValue ($oQuery, "TESTING"&5) $oQuery = _IEFormElementGetCollection ($oForm, 6) _IEFormElementSetValue ($oQuery, "TESTING"&6) $oQuery = _IEFormElementGetCollection ($oForm, 7) _IEFormElementSetValue ($oQuery, "TESTING"&7) $oQuery = _IEFormElementGetCollection ($oForm, 13) _IEFormElementSetValue ($oQuery, "TESTING"&13)

if you prefer form and object names good luck on that line 18 searching for them

as for getting lines
something like this works for me on google, maby itl work for yu maby itl not, never the less i think that you need to spend more time reading help and learning and testing codes (make special attention on String funcs) from help file Examples before trying it again with yahoo or some other site

#include <IE.au3> #include <String.au3> $oIE = _IECreate("<a href='http://www.google.com/search?q=chrome+opera' class='bbc_url' title='External link' rel='nofollow external'>http://www.google.com/search?q=chrome+opera"</a>) $sText = _IEBodyReadText ($oIE) ;~ MsgBox(0,'',$sText) $data1 = _StringBetween($sText, 'About ', ')') $ss1 = StringSplit($sText, 'Search Results',1) $ss2 = StringSplit($ss1[2],@CRLF,1) $data2 = StringReplace(StringReplace($ss2[1],' ...',@CRLF),'...Cached','')&@CRLF&$ss2[3] MsgBox(0,$data1[0]&')',$data2)

yes, yes, i know that some other freak can probably do this with StringRegExp in one line

Edited by bogQ, 08 December 2011 - 08:59 PM.

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project

Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.


#3 MaoMao



  • Active Members
  • 41 posts

Posted 11 December 2011 - 02:25 PM

Thanks for the nice examples. It helps. Will need more work to figure out the code before to continue.

Try to run the following code. Need advice for the following:
1. Enter the search action and submit the entry.
2. Display the search result message. Can not get it dsiplay in the msg box.

Plain Text         
#include <IE.au3> #include <String.au3> $oIE = _IECreate("http://www.google.com/advanced_search?hl=en") $oForm = _IEFormGetCollection ($oIE, 0) $oQuery = _IEFormElementGetCollection ($oForm, 1) _IEFormElementSetValue ($oQuery, "Chrome") $oQuery = _IEFormElementGetCollection ($oForm, 2) _IEFormElementSetValue ($oQuery, "Windows") $oQuery = _IEFormElementGetCollection ($oForm, 3) _IEFormElementSetValue ($oQuery, "download") $netinfo = _IEFormSubmit ($oForm)    ;(Test Line Error code) $sText = _IEBodyReadText ($netinfo)  ;(Test Line Error code) ;~ MsgBox(0,'',$sText) MsgBox(0,'msg',$sText)    ;(Test Line can not display text) $data1 = _StringBetween($sText, 'id=resultStats>', '<nobr>') $ss1 = StringSplit($sText, 'Search Results',1) $ss2 = StringSplit($ss1[1],@CRLF,1) $data2 = StringReplace(StringReplace($ss2[1],' ...',@CRLF),'...Cached','')&@CRLF&$ss2[3] ;MsgBox(0,$data1[0]&')',$data2) MsgBox(0,'Msg1',$data1) MsgBox(0,'Msg2',$data2)

Try to Retrieve Result in Msg box:

About 409,000,000 results (0.19 seconds)

Google Chrome - Free software downloads and software reviews ...

download.cnet.com/...Chrome/3000-2356_4-10881381.html - CachedSimilar
You +1'd this publicly. Undo
Review by Seth Rosenblatt - Free - Windows - Internet Browser25 Oct 2011 – Chrome beta (Windows (download) | Mac (download)), Chrome dev (Windows (download) | Mac (download)), and Chrome Canary (Windows ...

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users