Marc Posted January 1, 2023 Share Posted January 1, 2023 Hi all, here's a test snippet from a script I use daily. Worked fine, until roundabout last week. Problem is: I am checking for the next comic on the webpage. If the comic does not yet exist, the sourcecode contains the text <h1>404 Error</h1>. At least, that's the result in the Webbrowser. But I get a different sourcecode when using the edge browser or _InetGetSource. Especially the 404 Error-Tag is missing. Tried it with several variations of the UserAgent (my old value is "Mozilla / 5.0"). #include <INet.au3> ;HttpSetUserAgent('Mozilla / 5.0') HttpSetUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:10.0) Gecko/20100101 Firefox/10.0') ;HttpSetUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36') ; HttpSetUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36') $result = lfg(1985) MsgBox(0,"lfg", $result) Func lfg($start) $name = "lfg" & $start $x = _INetGetSource("http://www.lfg.co/page/" & $start & "/") ClipPut($x) If StringInStr($x, "<h1>404 Error</h1>") Then Return 404 Return "nope" EndFunc ;==>lfg Desired result of the test-script: a messagebox with 404. Current result of the test script: "nope". Any ideas what I'm doing wrong? best regards, Marc Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) Link to comment Share on other sites More sharing options...
Solution AutoBert Posted January 1, 2023 Solution Share Posted January 1, 2023 (edited) Quote Quote _INetGetSource Gets the source from an URL without writing a temp file #include <Inet.au3> _INetGetSource ( $sURL [, $bString = True] ) Parameters $sURL (The URL of the site.) eg 'http://www.autoitscript.com' $bString [optional] If True the data is returned in string format, otherwise binary format. Return Value Success: the read string and sets @extended to the number of bytes returned. Failure: an empty string and and sets the @error flag to non-zero. in a empty string can't be a 'error 404' : try this func: Func lfg($start) $name = "lfg" & $start $x = _INetGetSource("https://www.lfg.co/page/" & $start & "/") $iExt = @extended If @error Then Return 'error: ' & @error Else ClipPut($x) return $iExt & ' bytes read' EndIf EndFunc ;==>lfg it's returning the @error makro or the readed bytes (in this case the readed string is in clipboard). happy new year Edited January 1, 2023 by AutoBert Link to comment Share on other sites More sharing options...
Marc Posted January 1, 2023 Author Share Posted January 1, 2023 thank you very much - and happy new year to all, too Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL) 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