I must write a script that allows me make use of this website


(I have to utilize it a couple of hundred occasions, and that i don't seem like doing that by hand)

I've looked the web for ways how this may be done using Perl, and that i discovered World wide web::Mechanize, which appeared to become precisely what I had been searching for. However I have found the form on this website which I wish to use doesn't have title - its declaration line simply reads

<FORM METHOD="Publish" ACTION="./lga-form.cgi" ENCTYPE=multipart/form-data>

In the beginning I attempted not setting my World wide web::Mechanize object's form_title property, which provided this error message after i provided something for that form's current email address area:

Argument "my_email@address.com" is not number in number gt (>) at /usr/share/perl5/World wide web/Mechanize.pm line 1618.

Then i attempted setting form_title to '' and then ' ', however it was with no success, I merely got this message:

There's no form named " " at ./automate_LGA.pl line 40

What strategy is there to cope with forms which have no names? It might be most useful if a person on here could answer this - even when the solution points from using World wide web::Mechanize, as Among the finest to complete the job, (pretty much) regardless of how.

Thanks ahead of time!

A simple and much more robust way is by using the $mech->form_with_fields() method from World wide web::Mechanize to choose the shape you would like in line with the fields it consists of.

Simpler still, make use of the submit_form method using the with_fields option.

For example, to discover a form that has fields named 'username' and 'password', complete them and submit the shape, it's as simple as:


    with_fields => 


Doing the work by doing this has got the advantage when they shuffle their HTML around, altering an order from the forms within the HTML, or adding a brand new form prior to the one you are thinking about, your code will work.

I'm not sure about World wide web::Mechanize, nevertheless its Python equivalent, mechanize, provides you with a range of forms that you could iterate even when you do not know their names.

Example (obtained from its home page):

import mechanize

br = mechanize.Browser()

br.open("http://world wide web.example.com/")

for form in br.forms():

    print form

EDIT: searching within the paperwork of World wide web::Mechanize I discovered the $mech->forms() method, that may be the thing you need. Consider I'm not sure perl or World wide web::Mechanize, I'll leave there my python answer.

Okay, I've discovered the solution. I'm able to address the nameless form by its number (there's only one form around the web page, and so i suspected it might be number 1, also it labored). Here's a part of my code:

my $lga = World wide web::Mechanize->new()

my $address = 'my_email@address.com'

my $options = '-3 -o0 -d:4.0'

my $pdb_2   = "$_1 $_2"


$lga->success or die "LGA GET failn"


$lga->field('Address', $address)

$lga->field('Options', $options)

$lga->field('PDB_2', $pdb_2)


$lga->success or die "LGA Publish failn"