Sign in to follow this  
Followers 0
ancp

How downloading file from web with form post method

4 posts in this topic

Hi, all. I'am begginer in AutoIt. I need help with script how downloading any txt file from a web with form POST method. I know how to downloading any file with inetget (direct link), but I'am lost with this method downloading. Please, can anyone expert AutoIt help me with this problem? Target file must be downloaded to tmp folder without open a broser window (in the background). Thanks for any little example. Sorry for my bad English.

Example HTML(php) with desired file:

<html>
<head>
  <title>Title</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
</head>

<body>
<form method="POST" action="generating.php">
    <input type="radio" name="r1" id="r1rtf" value="rtf" checked><label for="r1rtf">Formated file</label>
    <input type="radio" name="r1" id="r1txt" value="txt"><label for="r1txt">Plain text file</label>
    <input type="radio" name="r1" id="r1pak" value="pak"><label for="r1pak">PAK file</label>
      <br>
      <br>
    <input type="text" name="k2,08,08,17" value="def_name">
    <input type="submit" name="k2,08,08,17" value="Create">
</form>
..
..
..
</body>
</html>

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <Inet.au3>
$source = _InetGetSource($link) ;Retrieves source from website
FileWrite(@ScriptDir & "\Text.txt", $source) ;Writes the file

Kurt :whistle:

Edited by _Kurt

Awaiting Diablo III..

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

to Kurt: Yes, of course! But this did not working, because i have'n direct URL to file!!! I wrote, that file is possible downloading after submit button as form POST method (file is generated from SQL database records ... i supposing).

Edited by ancp

Share this post


Link to post
Share on other sites

If you need to manipulate forms etc, see IE.au3 (IE Management section under UDFs in the helpfile).

Dale


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

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