Sign in to follow this  
Followers 0
jacky_ckw

Inetget Does Not Work

59 posts in this topic

hi all,

read thru some of the post made by others and it seems i'm not the only 1 having this problem.

the InetGet function seems not working at times.

in my office environment it works fine but when i get home to use it, it doesn't work.

furthermore, my home computer does not have firewall enabled. on the contary, office has firewall and it worked well.

i'm sure i'm not the only person having this problem.

:)


New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites



here is how the simple code works...

InetGet("http://www.yahoo.com/", "test.htm", 1, 0)

i even tried to ensure the proxy is based on my browers' settings by adding so...

but it think no use cos its default to do so.

HttpSetProxy(0)
InetGet("http://www.yahoo.com/", "test.htm", 1, 0)

New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

here is how the simple code works...

InetGet("http://www.yahoo.com/", "test.htm", 1, 0)

i even tried to ensure the proxy is based on my browers' settings by adding so...

but it think no use cos its default to do so.

HttpSetProxy(0)
InetGet("http://www.yahoo.com/", "test.htm", 1, 0)
works here >> win98se IE 5.5sp2

Share this post


Link to post
Share on other sites

both my office and home computers are WinXP SP2.

not sure what could be preventing the page from being downloaded...

is AutoIt able to download files from the internet without using the InetGet function?

:">


New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

give a quik try to this (scrap code NOT tested)

#Include <IE.au3>

$s_URL = "http://www.yahoo.com/"  
$o_object = ObjCreate("InternetExplorer.Application")
   If IsObj($o_object) Then
      $o_object.visible = 0
      $o_object.navigate ($s_URL)
         While _IEGetProperty($o_object, "busy") or _
            ((_IEGetProperty($o_object, "readyState") <> "complete") and (_IEGetProperty($o_object, "readyState") <> 4))
            Sleep(100)
         WEnd
      _IELoadWait($o_object)
    ;  $o_object.visible = $f_visible
EndIf
  
$temp1 = @TempDir & "\tmp.html" 
$text= "ciao"
;0 = Read mode
; 1 = Write mode (append to end of file)
; 2 = Write mode (erase previous contents)

$file = FileOpen($temp1, 2)
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
FileWrite($file, $text & @CRLF)
FileWriteLine($file, _IEBodyReadTXT($o_object))

FileClose($file)

$body = _IEBodyReadTXT($o_object)

;Run("Notepad.exe")
;:WinWaitActive("")
;ClipPut($body)
;ControlSetText("","","Edit1",ClipGet())

Func _IEBodyReadTXT($o_object)
    If IsObj($o_object.document) Then
        SetError(0)
        Return $o_object.document.body.innerHTML
    ;;;;;;_window.document.body.innerText
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc

_IEQuit($o_object)
Edited by Lapo

Share this post


Link to post
Share on other sites

thanks for the quick reply.

when i tried to run it, i get the error reading the file:

IE.au3

pls advise where i can get tat file? :)


New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

give a quik try to this (scrap code NOT tested)

OR ( working fine here) :

$objXMLHTTP = ObjCreate("Microsoft.XMLHTTP")
$objXMLHTTP.Open ("GET", "http://www.yahoo.com", False)
$objXMLHTTP.Send
$result = $objXMLHTTP.ResponseText

;$objXMLHTTP = Nothing

$temp1 = @TempDir & "\tmp.html"

$file = FileOpen($temp1, 1)
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
FileWrite($file, $result)

FileClose($file)
Edited by Lapo

Share this post


Link to post
Share on other sites

thanks for the quick reply.

when i tried to run it, i get the error reading the file:

IE.au3

pls advise where i can get tat file? :)

scripts and scraps

Lapo please use the [ code ] before the code and [ /code ] after the code tags without the spaces please


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

now i get unknown function name.

:)


New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

scripts and scraps

Lapo please use the [ code ] before the code and [ /code ] after the code tags without the spaces please

Sure .. sorry

EDIT:

But it's NOT simple to copy and paste then ... is there a trick

Edited by Lapo

Share this post


Link to post
Share on other sites

i have gotten the ie.au3 file, i supposed its to be placed in the C:\Program Files\AutoIt3\Include?

when i run the 1st code you gave me, i got this error

If IsObj($o_object.elements) Then
If IsObj($o_object.e^ERROR

Error: Unable to parse line.

New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

i have gotten the ie.au3 file, i supposed its to be placed in the C:\Program Files\AutoIt3\Include?

when i run the 1st code you gave me, i got this error

If IsObj($o_object.elements) Then
If IsObj($o_object.e^ERROR

Error: Unable to parse line.

If I remember you need au3 beta for IE.au3 read here :

http://www.autoitscript.com/forum/index.php?showtopic=13398

Edit :

YES here :

Important: AutoIt Beta 3.1.1.63 or higher is now required to the use of the ObjName function. Beta downloads are here :

http://www.autoitscript.com/autoit3/files/beta/autoit/

Edited by Lapo

Share this post


Link to post
Share on other sites

sorry, after installing the beta and dowload the IE.au3 i still get the same error

If IsObj($o_object.elements) Then
If IsObj($o_object.e^ERROR

Error: Unable to parse line.

New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

sorry, after installing the beta and dowload the IE.au3 i still get the same error

If IsObj($o_object.elements) Then
If IsObj($o_object.e^ERROR

Error: Unable to parse line.
Ok i must go now .... try this vbs :

On Error Resume Next
x = TextFromHTML("http://www.yahoo.com/") 
'WScript.Echo x 
Function TextFromHTML(URL) 
  set ie = createobject("internetexplorer.application") 
  ie.navigate URL 
  do until ie.readystate = 4 : wscript.sleep 10: loop 
  TextFromHTML = ie.document.body.outerHtml
  ie.quit 
End Function 
filename = "Yahoo.html" 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set newf = fso.createtextfile(filename) 
newf.WriteLine x

save as yahoo.vbs and try it

Edited by Lapo

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

sorry, after installing the beta and dowload the IE.au3 i still get the same error

If IsObj($o_object.elements) Then
If IsObj($o_object.e^ERROR

Error: Unable to parse line.
http://www.autoitscript.com/forum/index.ph...lements%2Berror

I go now ... ciao

Edit :

PS:

tray again InetGet

Edited by Lapo

Share this post


Link to post
Share on other sites

thanks Lapo,

i still cant get it to work. do you have any simpler code from release version that can download files from internet?

:">


New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

:) i managed to get the 1st script you gave me to work.

there was no error so i thought it might have work until i edited the part

from

$temp1 = @TempDir & "\tmp.html"

to

$temp1 = @ScriptDir & "\tmp.htm"

but i'm not so familiar with the Beta version yet.

is there any other way i can get AutoIt to download a page using InetGet? :mellow:


New to script...But getting the hang of it.

Share this post


Link to post
Share on other sites

:) i managed to get the 1st script you gave me to work.

there was no error so i thought it might have work until i edited the part

from

$temp1 = @TempDir & "\tmp.html"

to

$temp1 = @ScriptDir & "\tmp.htm"

but i'm not so familiar with the Beta version yet.

is there any other way i can get AutoIt to download a page using InetGet? :mellow:

A page? I guess you could use _InetGetSource()?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

cant find that in release version 3.11

how come everyone is using the beta version already? managed to find that _InetGetSource from the beta help file.

but it states very little, as it only states getting the souce without writing to a temp file. so now i'm not sure how i can create the temp file by running that...

:)


New to script...But getting the hang of it.

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  
Followers 0