MaoMao Posted November 28, 2011 Posted November 28, 2011 (edited) Please help for Autoit Google Advance SearchTrying to perform Advance search in Google Advance search:http://www.google.com/advanced_searchHow 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.comHow to get multiple result in th site to a file.expandcollapse popup#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) ') $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 ; OperaTesting code not working well. Please help.Expected ResultBookTraget.xls Edited November 28, 2011 by MaoMao
bogQ Posted December 8, 2011 Posted December 8, 2011 (edited) lets answer your first question#include <IE.au3> $oIE = _IECreate("http://www.google.com/search?q=chrome+opera") $oIE = _IECreate("http://search.yahoo.com/search?p=chrome+opera")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 so if you need advanced search lets at least play with it like this#include <IE.au3> $oIE = _IECreate("http://www.google.com/advanced_search") $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 themas for getting linessomething 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("http://www.google.com/search?q=chrome+opera") $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 December 8, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - 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.
MaoMao Posted December 11, 2011 Author Posted December 11, 2011 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.#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:1)SearchAbout 409,000,000 results (0.19 seconds) 2)Google Chrome - Free software downloads and software reviews ...download.cnet.com/...Chrome/3000-2356_4-10881381.html - CachedSimilarYou +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 ...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now