lordsocke Posted March 4, 2018 Share Posted March 4, 2018 Hey there, I´m using a very simple codeline to download a google search. This repeats every 3 seconds. Sometimes InetRead() works totally fine and sometimes its just delivering an empty string. I´ve been googling a bit around and there are some more guy´s seems to have that problem but nobody really got a solution or a work around. $url = ("https://www.google.de/search?q="&$text) $text =BinaryToString(InetRead($url,16)) FileWrite("text.txt",$text) Link to comment Share on other sites More sharing options...
Danp2 Posted March 4, 2018 Share Posted March 4, 2018 You'll need to change your code to check the value of @error following the call to InetRead. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
lordsocke Posted March 4, 2018 Author Share Posted March 4, 2018 48 minutes ago, Danp2 said: You'll need to change your code to check the value of @error following the call to InetRead. Error flag is at 13 Link to comment Share on other sites More sharing options...
Danp2 Posted March 4, 2018 Share Posted March 4, 2018 Some discussion here, but it doesn't explain the error. Similar discussions here. Even if we don't know the reason for the error, you should still be able to properly retry the command a few times until it works. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
lordsocke Posted March 4, 2018 Author Share Posted March 4, 2018 1 hour ago, Danp2 said: Some discussion here, but it doesn't explain the error. Similar discussions here. Even if we don't know the reason for the error, you should still be able to properly retry the command a few times until it works. for my script it would be nessecary that is works. Do you know any workaround? Link to comment Share on other sites More sharing options...
Bilgus Posted March 4, 2018 Share Posted March 4, 2018 Instead use inetget() Local Const $INET_DOWNLOADBACKGROUND = 1 $text = "google" $url = ("https://www.google.com/search?q="&$text) GetPage($url) Func GetPage($sUrl) Local $WdataAvail = Inetget($sUrl, @ScriptDir & "\pagetext.txt", 1, $INET_DOWNLOADBACKGROUND) If InetGetInfo ($WdataAvail,2) <> True Then for $i = 1 to 30 ;continue for 30 seconds Sleep(1000) If InetGetInfo ($WdataAvail,2) = True Then ExitLoop EndIf Next If InetGetInfo ($WdataAvail,3) <> True Then ;Check for success InetClose($WdataAvail) Msgbox(0,"Error", "Failed") Exit EndIf EndIf InetClose($WdataAvail) EndFunc lordsocke 1 Link to comment Share on other sites More sharing options...
lordsocke Posted March 4, 2018 Author Share Posted March 4, 2018 2 minutes ago, Bilgus said: Instead use inetget() Local Const $INET_DOWNLOADBACKGROUND = 1 $text = "google" $url = ("https://www.google.com/search?q="&$text) GetPage($url) Func GetPage($sUrl) Local $WdataAvail = Inetget($sUrl, @ScriptDir & "\pagetext.txt", 1, $INET_DOWNLOADBACKGROUND) If InetGetInfo ($WdataAvail,2) <> True Then for $i = 1 to 30 ;continue for 30 seconds Sleep(1000) If InetGetInfo ($WdataAvail,2) = True Then ExitLoop EndIf Next If InetGetInfo ($WdataAvail,3) <> True Then ;Check for success InetClose($WdataAvail) Msgbox(0,"Error", "Failed") Exit EndIf EndIf InetClose($WdataAvail) EndFunc Thanks for that, but I dont think its gonna be fast enough for me... the skript is 0.8sec for now per runtime Link to comment Share on other sites More sharing options...
Bilgus Posted March 4, 2018 Share Posted March 4, 2018 expandcollapse popupLocal Const $INET_DOWNLOADBACKGROUND = 1 Local $aRet Local $aHandles[1000] Local $iCt = 0 $text = "google" $url = ("https://www.google.com/search?q="&$text) GetPage($url) CloseHandles() Func GetPage($sUrl) Local $WdataAvail = Inetget($sUrl, @ScriptDir & "\pagetext.txt", 1) $aRet = InetGetInfo ($WdataAvail) If IsArray($aRet) and $aRet[2] <> True Then for $i = 1 to 300 ;continue for up to 30 seconds $aRet = InetGetInfo ($WdataAvail) If $aRet[2] = True Then ExitLoop EndIf Sleep(100) Next If Not IsArray($aRet) or $aRet[3] <> True Then ;Check for success InetClose($WdataAvail) Msgbox(0,"Error", "Failed") CloseHandles() Exit EndIf EndIf $iCt += 1 $aHandles[$iCt] = $WdataAvail if $iCt >= 999 Then CloseHandles() EndFunc func CloseHandles() for $i = 0 to $iCt InetClose($aHandles[$i]) Next $iCt = 0 EndFunc If you are calling it repeatedly you could do something like this.. probably need to tweak it a bit to get it to its full potential but you get the idea Link to comment Share on other sites More sharing options...
lordsocke Posted March 4, 2018 Author Share Posted March 4, 2018 1 minute ago, Bilgus said: expandcollapse popupLocal Const $INET_DOWNLOADBACKGROUND = 1 Local $aRet Local $aHandles[1000] Local $iCt = 0 $text = "google" $url = ("https://www.google.com/search?q="&$text) GetPage($url) CloseHandles() Func GetPage($sUrl) Local $WdataAvail = Inetget($sUrl, @ScriptDir & "\pagetext.txt", 1) $aRet = InetGetInfo ($WdataAvail) If IsArray($aRet) and $aRet[2] <> True Then for $i = 1 to 300 ;continue for up to 30 seconds $aRet = InetGetInfo ($WdataAvail) If $aRet[2] = True Then ExitLoop EndIf Sleep(100) Next If Not IsArray($aRet) or $aRet[3] <> True Then ;Check for success InetClose($WdataAvail) Msgbox(0,"Error", "Failed") CloseHandles() Exit EndIf EndIf $iCt += 1 $aHandles[$iCt] = $WdataAvail if $iCt >= 999 Then CloseHandles() EndFunc func CloseHandles() for $i = 0 to $iCt InetClose($aHandles[$i]) Next $iCt = 0 EndFunc If you are calling it repeatedly you could do something like this.. probably need to tweak it a bit to get it to its full potential but you get the idea looks pretty, thanks a los im going to test tomorrow 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