Jump to content

Strange source with _InetGetSource


Go to solution Solved by AutoBert,

Recommended Posts

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/ Safari/537.36')
; HttpSetUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36')

$result = lfg(1985)
MsgBox(0,"lfg", $result)

Func lfg($start)
    $name = "lfg" & $start

    $x = _INetGetSource("http://www.lfg.co/page/" & $start & "/")
    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,


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

  • Solution


Gets the source from an URL without writing a temp file

#include <Inet.au3>
_INetGetSource ( $sURL [, $bString = True] )


$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
        return $iExt & ' bytes read'
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 by AutoBert
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...