Matt
Matt

Reputation: 826

write a code to fill a form on the web and read one of the elements

I am periodically checking a website which requires me to fill a form. When I fill the form, a window pops up which includes the information I am looking for.

I was wondering if there is a way to write a program to fill the form and extract the fields that are of importance to me.

If possible,

What language is easier for doing so?

Is there any way to read one of the elements on the window that pops up? (When you right-clik on an item and select inspect element)

Could you please provide links and tutorials to implement this, so that I could write the program ASAP?

Update: The solution using VBScript is posted. I would appreciate it if you post other solutions that could be used under OSX or Linux (Preferably OSX)

Upvotes: 0

Views: 924

Answers (1)

karthik manchala
karthik manchala

Reputation: 13640

Yes we can.. one way to do it using VBS is here:

Dim objIE

    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = 1 

    objIE.navigate "<login url>"
    WScript.Echo "Opening login page..."
    WScript.Sleep 100
    Do while objIE.busy
    Wscript.sleep 200
    Loop

    WScript.Echo "Setting credentials..."
    objIE.Document.getElementByID("ap_email").Value = user 'id of the input element

    objIE.Document.getElementByID("ap_password").Value = pass

    WScript.Echo "Email and password set!"

    Call objIE.Document.Forms(0).submit

HTH!

Upvotes: 1

Related Questions