Jump to content

Send HTML form without IE


Rad
 Share

Recommended Posts

Wondering if there are any ways to send a form, including a "file" input, without using Internet Explorer. Making a gallery that allows users to manage it via software and if I can get this to work and be sent back the raw text of the page (which will output errors, etc), thats all I will need.

FTP is not an option though, I know game maker was able to do this - so I assume there is a DLL out there, but I have no experience with DLL's and don't even understand how they work.

Searched the forum but... Don't know what to search for. I tried Ajax, but that returned a remote desktop script and a pure autoit webserver. Not what I am looking for... ;)

What I need to do, is send a form -- or some other type of data that will upload an image through http -- and submit a username and password. I figured storing sessions/cookies with autoit would be a hassle, and I would very much rather not using any of the IE functions.

Link to comment
Share on other sites

Thanks for the suggestion! I was currently looking at wGet but I don't think it can do the 'send' portion.

Your suggestion looks like what I need, but I'm not sure what to do with the source code.

*snip*

Edit: Using the cURL download wizard I was able to get a pre-compiled version of curl.exe, with SSL disabled (Not using it).

I was able to upload my file AND include the username/password field using

curl.exe -F "username=testuser" -F "password=testpass" -F "file=@C:\Documents and Settings\Administrator\My Documents\My Pictures\myimage.jpg" -F press=Upload http://url.com/submit.php

Thanks for showing me this. I learned a bit and can finally finish my program without using a public ftp account. I also see potential for this cURL in my program for other things.

It would be great if I could get a progress bar out of this. If I run it as a .bat, it displays transfer rate, amount transferred, percentage etc. It can also do a progress bar. Is there any way to make this (using RunWait()) to output this data in autoit-usable format? I will read the documentation some more, but you might already know...

Edited by Rad
Link to comment
Share on other sites

Hello,

i use curl to put picturefiles on public servers like imageshack.us.

in commandline curl communicates with their html form and response contains the picture-url.

the only thing i dont know is how to get a progressbar from curl into autoit-gui. but i am also intrested. if you can handle it i would like to know : )

thank you and have a nice christmas, andy (germany)

Edited by andygo
Link to comment
Share on other sites

I have some good news, but I wish it were cleaner. If you improve this please post the changes, I'm not very good at detecting errors... ;)

You can read in from stderr (using STDErrRead($result) where $result is the stream from the Run command. To do this you need to store the actual result from the request to a file (aka the source code of the website). And for that, you add -o curl.tmp to the command. I don't know why it's stderr and not stdin, though I don't really know the difference regardless.

Now, after the Run() you can use StderrRead() to get the "progress" of the file. If you run the command line in a console you can see how this is formatted.

I made this function to collect the data. You will likely need to mess with it, I found a few times when the arrays were incorrect and tried to prevent them.

#cs
====================================================================================================
Description:
    Takes the default stderrread() data of a curl.exe command converts it to a usable format
Parameters:
    curlGetProgress($sStdErr)
Returnvalues:
    Array {
        0: Total %
        1: Total Bytes
        2: Download %
        3: Download Bytes
        4: Upload %
        5: Upload Bytes
        6: Download Rate
        7: Upload Rate
        8: Estimated Time
        9: Time Elapsed
        10: Time Left
        11: Current Speed (Upload or Download, I assume)
    }
Author:
    Rad
Notes:
    This is only enabled if your curl command outputs a progress meter (NOT progress "bar"). From
    the curl documentation:
        "If you want a progress meter for HTTP POST or PUT requests, you needto redirect the
        response output to a file, using shell redirect (>), -o [file] or similar."
====================================================================================================
#ce
func curlGetProgress($stream)
    local $regexp = stringregexp($stream, "[0-9\:\-]{1,}[a-zA-Z\:]{0,}", 3)
    local $err = @error
    local $array[12]
    if $err > 0 then ;The regexp had an error, which is likely caused by the formatting of the stream.
        seterror($err+1)
        return $err+1
    Else
        if isarray($regexp) Then 
            for $i = 0 to 11
                $array[$i] = $regexp[$i]
            Next
            return $array
        Else ;The regexp didn't catch an error, but there was only one match
            seterror(1)
            return -1
        EndIf
    EndIf
EndFunc
Edited by Rad
Link to comment
Share on other sites

wow great thing man!!!

with your help i codet a little test:

#include <Constants.au3>
#cs
Array {
        0: Total %
        1: Total Bytes
        2: Download %
        3: Download Bytes
        4: Upload %
        5: Upload Bytes
        6: Download Rate
        7: Upload Rate
        8: Estimated Time
        9: Time Elapsed
        10: Time Left
        11: Current Speed (Upload or Download, I assume)
    }
#ce
Local $foo = run ("curl.exe -o localfile.test http://dl.google.com/picasa/picasa3-setup.exe", "D:\=Script=\curl\", @SW_HIDE, $STDERR_CHILD ), $line
ProgressOn("Progress Meter", "curl.exe test", "0 percent")
While ProcessExists ("curl.exe")
    $line = StderrRead($foo)
    $line = StringRegExp($line, '\d+', 3)
    if NOT @error then ProgressSet( $line[0], $line[0] & " percent")
    sleep(50)
Wend
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

MsgBox(0, "Debug", "Exiting...")

this is exactly what i want! ;)

Link to comment
Share on other sites

  • 7 months later...

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