Jump to content
Sign in to follow this  
Morthawt

Having issues reading a web page source (weird)

Recommended Posts

Morthawt

#include <String.au3>
#include <Inet.au3>
HttpSetUserAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")

$URL = 'http://www.worldoftanks-wot.com/mods/'
$sSource = _INetGetSource($URL, True)
ConsoleWrite($sSource)

$sSource = BinaryToString(InetRead($URL, 1))
ConsoleWrite($sSource)

I have read source code into a variable more times than I can count. Right now the url: http://www.worldoftanks-wot.com/mods/ will not let me view the source code, even putting in a standard browser agent string. I cannot fathom what would be preventing this? I have tried two different methods to get the source code.

Share this post


Link to post
Share on other sites
HeJake

This should work :)

$URL = "http://www.worldoftanks-wot.com/mods/"

$oHTTP = ObjCreate('winhttp.winhttprequest.5.1')
$oHTTP.Open('GET', $URL, False)
$oHTTP.Send()
$oHTTP.WaitForResponse
$HTTPSource = $oHTTP.Responsetext

MsgBox(0, '', $HTTPSource)

Share this post


Link to post
Share on other sites
Morthawt

See I don't use that side of Autoit. Do you have any ideas why the classic types of approach won't retrieve the source code? I have never had this happen before. It is mind boggling.

Edited by Morthawt

Share this post


Link to post
Share on other sites
HeJake
Well, you can also try this one:
#include <IE.au3>

$GUI = GUICreate('', 0, 0, 0, 0)
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, -1, -1, 0, 0)
GUISetState(@SW_HIDE)
_IENavigate($oIE, $URL)
$sSource = _IEDocReadHTML($oIE)
MsgBox(0, '', $sSource)

There might be some script causes you to not receive source code using your way.

Blame on me, this works:

#include <String.au3>
#include <Inet.au3>
HttpSetUserAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")

$URL = 'http://www.worldoftanks-wot.com/mods'
$sSource = _INetGetSource($URL)
ConsoleWrite($sSource)
Edited by HeJake

Share this post


Link to post
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
Sign in to follow this  

×