Jump to content

Help Auto Google Advance Search


Recommended Posts

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.

#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')


;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
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)

; Separate Text file LogNames.txt
;  LogNames.txt
; Firefox
; Chrome
; Internet Explorer
; Safari
; Opera

Testing code not working well. Please help.

Expected ResultBookTraget.xls


Edited by MaoMao
Link to comment
Share on other sites

  • 2 weeks later...

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 :D

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 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("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]

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

Edited by bogQ

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.

Link to comment
Share on other sites

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]

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 ...

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...