Jump to content

How to collect data in web page search engine


MaoMao
 Share

Recommended Posts

Can anyone help for how to submit a web site search function.

Need to enter multiple info to search engine.

Display result in message page for further use.

;Get the html code of the results page
#include <IE.au3>
#include <String.au3>
Local $Keyword = 'Chrome'
Local $Keyword1 = 'Windows'
Local $Keyword2 = 'download'
; Example Site: Local $SearchEngine = 'http://www.ebay.com/sch/ebayadvsearch/?_skipfnorm=1&rt=nc'
; Example Site: Local $SearchEngine = 'http://www.hotels.com/'   

; Program loop get info from web page
Local $SearchEngine = 'http://www.google.com/advanced_search?hl=en'
$oIE = _IECreate($SearchEngine)
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 1)   ; submit entries
_IEFormElementSetValue ($oQuery, $Keyword)
$oQuery = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oQuery, $Keyword1)
$oQuery = _IEFormElementGetCollection ($oForm, 3)
_IEFormElementSetValue ($oQuery, $Keyword2)
$netinfo = _IEFormSubmit ($oForm, 1)     ;(?Test Line not able to get the result )
$nText = _IEBodyReadText ($netinfo)   ;(??????Test Line not able to read text)
MsgBox(0,'Text',$nText)
$sText = _IEBodyReadText ($oForm)  ;(??????Test Line not able to read text)
MsgBox(0,'msg', $sText )     ;(Test Line can not display text)
;Get the html code of the results page
$Url = $netinfo
; Google one line test code
; Local $Url = 'http://www.google.com/search?q='&$Keyword&'+%22'&$Keyword1&'%22+'&$Keyword2&'&hl=en&num=10&lr=&ft=i&cr=&safe=images'

Local $Html = BinaryToString(InetRead($Url))
;Get only the body code
$Html = StringMid($Html,StringInStr($Html,'<body'))
;Remove the javascripts
$Html = StringRegExpReplace($Html,'(?s)(?i)<script.+?script>','')
;Retrieve the visible text
Local $Text = StringRegExpReplace($Html,'(?s)<.+?>','')
;Display the visible text
MsgBox(0,'','Page text:'&@CRLF&$Text)
Edited by MaoMao
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
 Share

  • Recently Browsing   0 members

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