Jump to content

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
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
Posted
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.

Posted (edited)

works for me too. I tested the top version of code too, it works without ie being opened and returns the body text of that page

Edited by Earthshine

My resources are limited. You must ask the right questions

 

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!

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...