blackandwhite

<'WinHTTP.au3'> submit form by clicking on image button with _WinHttpSimpleFormFill

5 posts in this topic

#1 ·  Posted (edited)

Hi  people :D

is it possible to fill form and submit by clicking on image that have code like:

<input alt="Add Photos" value="Add Photos" class="bv" src="https://fbstatic-a.akamaihd.net/rsrc.php/v2/yb/r/6V3eTUQPZ26.png" type="image" name="view_photo">

using _WinHttpSimpleFormFill?

Edited by blackandwhite

Share this post


Link to post
Share on other sites



Currently not. I wasn't satisfied with the syntax so I left that out. Besides for some reason no one ever asked for it.

...I'm gonna try to add the feature before the new release.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

hello trancexx :)

3 minutes ago, trancexx said:

Currently not. I wasn't satisfied with the syntax so I left that out. Besides for some reason no one ever asked for it.

thats sad :'(

I'm trying to modify your code from here:

to upload more than 3 files

for this I need to click on image with source above, or return to upload page after 1st 3 files, but last way not return previews for these pictures

#include "WinHttp.au3"
#include <array.au3>

Global $sFB_Email = "email@domain.com" ;<- your email here
Global $sFB_sPassword = "password" ;<- your password here
Global $sGroupID = "group_id" ; group ID you want to post to

$sPic = FileOpenDialog('2 or More Files', @DesktopDir, "Images (*.jpg;*.bmp;*.gif;*.png)", 4 + 1) ; choose a file you want to post
Global $splits = StringSplit($sPic, '|')
Global $dim = UBound($splits) - 1

If $sPic Then MsgBox(0,'',FB_PostPicToGroup($sGroupID, $sPic),1)

Func FB_PostPicToGroup($sGroupID, $sPic)

    ; Open session
    Local $hOpen = _WinHttpOpen()
    ; Connect
    Local $hConnect = _WinHttpConnect($hOpen, "https://m.facebook.com/")

    ; Login first (by filling login form)
    Local $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle
            "login.php", _ ; target page
            "login_form", _ ; form identifier
            "name:email", $sFB_Email, _ ; first field identifier paired with field data
            "name:pass", $sFB_sPassword) ; second field identifier paired with data

    ; Navigate to the Group and ask for pic upload
    Local $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle
            "/groups/" & $sGroupID, _ ; target page
            "index:1", _ ; form identifier (by index here, because id or name doesn't exist)
            "name:view_photo", True, _ ; identify submit control and click it
            "[RETURN_ARRAY]") ; return array because current URL is needed

    ;FileWrite('s1.html',$aRead[1]) ; upload page source
    
    ; Read current URL (go with the flow)
    Local $aURL = _WinHttpCrackUrl($aRead[2])


    $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle
                        $aURL[6] & $aURL[7], _ ; target page
                        Default, _ ; form identifier (default is used for simplicity because it's the only form on that page)
                        "name:file1", $splits[2], _
                        "name:file2", $splits[3], _
                        "name:file3", $splits[4], _
                        "[RETURN_ARRAY]")

                        ;_ArrayDisplay($aRead, 'return after 3 files')

            ;FileWrite('s2.html',$aRead[1]) ;page with preview

        ;;;;;;;;;;;;Return to previous page and upload again next 3 files
        
    $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle
                        $aURL[6] & $aURL[7], _ ; target page
                        Default, _ ; form identifier (default is used for simplicity because it's the only form on that page)
                        "name:file1", $splits[5], _
                        "name:file2", $splits[6], _
                        "name:file3", $splits[7], _
                        "[RETURN_ARRAY]")

    FileWrite('next 3.html',$aRead[1]) ;here must be preview but nothing

                        $aURL = _WinHttpCrackUrl($aRead[2])

        $aRead = _WinHttpSimpleFormFill($hConnect, _ ; connection handle
            $aURL[6] & $aURL[7], _ ; target page
            Default, _ ; form identifier (by index here, because id or name doesn't exist)
            "name:view_post", True, _ ; identify submit control and click it
            "[RETURN_ARRAY]")

                            ;FileWrite('s4.html',$aRead[1])
    ; Close handles
    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)

    ; Bye...
    ;Return $iSuccess
EndFunc

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

may be better to use mobile version of fb for chrome?

I don't know will there accept passing multiple files or not, but when I use

_WinHttpOpen('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2632.0 Safari/537.36')

it returns version for firefox

Edited by blackandwhite

Share this post


Link to post
Share on other sites
22 hours ago, trancexx said:

...I'm gonna try to add the feature before the new release.

ok, Can you explain me pls why I can't return back and get the page with upload form with previews of already uploaded 1st 3 files? (this is only 1 way for me to avoid submit by clicking on image)

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