faustf Posted March 9, 2017 Share Posted March 9, 2017 hi guys i want extract , at amazon search page , a name of product searched ,price and foto , and put result in listview i try to do a simple script in this mode Local $urlAmaS = "https://www.amazon.it/s/ref=nb_sb_noss?__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&url=search-alias%3Daps&field-keywords=" _Amazon_Search("i7", $urlAmaS) Func _Amazon_Search($frases, $url, $Hide = 0, $slow = 0) If $Hide = 0 Then $Hide = 1 EndIf If $slow = 0 Then $slow = 1000 EndIf Global $oIE = _IECreate($url&$frases, 0, $Hide, 1, 1) ; <--- 0011 invisible explorer <--- 0111 visible explorer _IELoadWait($oIE) Sleep($slow) Local $sText = _IEBodyReadText($oIE) Local $iFindBadPage = StringInStr($sText, "This page can’t be displayed") If $iFindBadPage <> 0 Then If ProcessExists("iexplore.exe") Then ; Check if the internet esplorer process is running. ProcessClose("iexplore.exe") EndIf Sleep($slow) $oIE = _IECreate($url&$frases, 0, $Hide, 1, 1) ; <--- 0011 invisible explorer <--- 0111 visible explorer _IELoadWait($oIE) EndIf Local $sLHtml = _IEBodyReadHTML($oIE) Local $aL = StringRegExp($sLHtml, 'href="(.*?)"><img src="(.*?)" srcset="(.+?)title="(.*?)" href="', 3) _ArrayDisplay($aL) EndFunc ;==>_Amazon_Search but the regrexp not work correct , anyone can help me ??? thankz so much at all Link to comment Share on other sites More sharing options...
gruntydatsun Posted March 10, 2017 Share Posted March 10, 2017 What is an example value of $sLHtml? Link to comment Share on other sites More sharing options...
mikell Posted March 10, 2017 Share Posted March 10, 2017 When possible and with the usual precautions, this approach (much faster) looks better #Include <Array.au3> $sTarget = "https://www.amazon.it/s/ref=nb_sb_noss?__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&url=search-alias%3Daps&field-keywords=" & "i7" $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", $sTarget, False) $oHTTP.Send() $s = BinaryToString($oHTTP.ResponseText) $oHTTP = 0 ;filewrite("1.txt", $s) Local $aL = StringRegExp($s, '(?s)href="([^"]+)"><img src="([^"]+)"\h*srcset="[^"]+.*?title="([^"]+)" href="', 3) _ArrayDisplay($aL) kylomas 1 Link to comment Share on other sites More sharing options...
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