Jump to content
pintas

[SOLVED] Get text from website not possible

Recommended Posts

Posted (edited)

Hi. I'm trying to get text from a website and later save it to a txt file.

When i use a specific url it doesn't work. It gets nothing.

So, if i use this code, it works:

#include <IE.au3>

$MainForm = GUICreate("hidden",0,0,0,0)
$oIE = _IECreateEmbedded() ; embedded ie window
GUICtrlCreateObj($oIE, 99999, 99999, 0, 0)
GUISetState(@SW_HIDE)
$mUrl = "www.citronresearch.com"

_dostuff()

while 1
Sleep(100)
WEnd

func _dostuff()
_IENavigate($oIE, $mUrl)
Local $sText = _IEBodyReadText($oIE)
ConsoleWrite($sText)
MsgBox($MB_SYSTEMMODAL, "Body Text", $sText)
Exit
EndFunc

But if i use this specific url, it doesn't.:

#include <IE.au3>

$MainForm = GUICreate("hidden",0,0,0,0)
$oIE = _IECreateEmbedded() ; embedded ie window
GUICtrlCreateObj($oIE, 99999, 99999, 0, 0)
GUISetState(@SW_HIDE)
$mUrl = "http://www.planalto.gov.br/ccivil_03/_Ato2015-2018/2018/Lei/L13709.htm"

_dostuff()

while 1
Sleep(100)
WEnd

func _dostuff()
_IENavigate($oIE, $mUrl)
Local $sText = _IEBodyReadText($oIE)
ConsoleWrite($sText)
MsgBox($MB_SYSTEMMODAL, "Body Text", $sText)
Exit
EndFunc

Any idea how to get the text from this specific url?

i also can't get the source from that url using InetGetSource. I get this error:

<noscript>Please enable JavaScript to view the page content.<br/>Your support ID is:  3084623253408755162.</noscript>

 

Edited by pintas

Share this post


Link to post
Share on other sites
Posted (edited)

You need to wait for the page to load.  Either put 1 as 3rd parameter of IENavigate or use _IELoadWait...

By default, Navigate waits.  So I tested your script and it works for me. 

Edited by Nine

Share this post


Link to post
Share on other sites
1 hour ago, Nine said:

You need to wait for the page to load.  Either put 1 as 3rd parameter of IENavigate or use _IELoadWait...

Thanks @Nine I tried that, but it didn't work. I still get a blank message box.

Share this post


Link to post
Share on other sites
Posted (edited)

Ok, i think i have a browser that's somehow hijacking the script.

I'll make some more tests.

Thanks guys!

Edit: Ok, got it to work. My browser was trying to steal the focus from IE. Thank you so much guys!

Edited by pintas
Got it working!

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

×
×
  • Create New...