Jump to content

Possible to post and get http from AutoIt?


LukeP
 Share

Recommended Posts

Is it possible to retrieve or post a web page from AutoIt3?

I would like to keep track of some results. The best way to do it would be to use post http to php web site, which would in turn update the database.

Is it possible?

thank you,

Luke

Link to comment
Share on other sites

Is it possible to retrieve or post a web page from AutoIt3?

I would like to keep track of some results. The best way to do it would be to use post http to php web site, which would in turn update the database.

Is it possible?

thank you,

Luke

<{POST_SNAPBACK}>

yes it is possible to do both. for retrieval, there is the quick and easy inetget() function (details in helpfile) for everything else with working with interacting with webpages, check out dale's ie.au3 (links are all over the forum or in his signature)
Link to comment
Share on other sites

I would imagine that a POST request is also achievable using the beta's TCP...() functions. I would love to be able to make POST requests in this fashion -- I'll take a look at it one day unless someone beats me to it!

Link to comment
Share on other sites

There are pretty straight-forward ways to do this with IE.au3

Retrieves are very simple as you can navigate to a page and then read the data returned. There is a function in IE.au3 for retrieving the HTML in the body tab of the document - _IEBodyReadHTML. I have a function to get all of the HTML on a page ready for the next release, but in the meantime you can use $oIE.document.getElementsByTagName("HTML").item(0).outerHTML

There are a couple of ways to Post. One is that the .Navigate method has a PostData parameter (but I don't support it directly in IE.au3). The other way to do it however is to create a webpage on the fly (you can use _IECreate and then _IEBodyWriteHTML) and create a form on that page with your own HTML -- then use IE.au3 functions to fill the form and submit it.

This may or may not make a lot of sense straight up, but if you want to give it a go and ask for more help, this would make a good example.

Dale

Edit: I forgot that I also wanted to mention the INetGet command in AutoIt and the COM interface WinHttp.WinHttpRequest - search the forum for some examples

Is it possible to retrieve or post a web page from AutoIt3?

I would like to keep track of some results. The best way to do it would be to use post http to php web site, which would in turn update the database.

Is it possible?

thank you,

Luke

<{POST_SNAPBACK}>

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

The IE automation library would be one way of achieving this, but might it be overkill for a function that a Telnet client can handle? Wouldn't this sort of thing therefore only require a couple TCP...() calls with a specially formatted string?

I don't have much idea how to use those functions but a read of the help file suggests that this might be close:

local $socket, $page
local $data = "POST /form.cgi HTTP/1.1" & @CRLF _
    & "User-Agent: AutoIt/3.1" & @CRLF _
    & "Content-Type: application/x-www-form-urlencoded" & @CRLF _
    & "Content-Length: 33" & @CRLF _
    & @CRLF _
    & "name1=value1&name2=value2&etc=etc"

tcpStartup()
$socket = tcpConnect("123.210.12.10", 80)
tcpSend($socket, $data)

; response from server will be HTML + headers
; (not too sure how to get that back)

; $page = tcpRecv(...)

tcpCloseSocket($socket)
tcpShutdown()

Am I very far off here?

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...