query_form hell

A

Alythh

I fear I don't understand correctly the method query_form in URI::URL
(and perldoc didnt help so much).

I need to access a page that has to be obtained by GET method in a
form.
I found that simply I can use
my $url = url($address);
$url->query_form(key1 => value1, ...);
$content = get($url);

but...

1st, I didnt understand how to point query_form to the right form if
the page contains many: by which keyword do I identify it?

2nd, I don't understand the values to insert in query_form

Practically, I'm trying to automate the download of the current issue
of PRL at http://prl.aps.org/, where I have:

<b>Recent and Future Issues</b><form method="GET"
action="http://link.aps.org/newfind/">
<input type="hidden" name="jrnl" value="prl">
<p><select name="issue" size="1">
<option value="v91i18"selected>Vol. 91, No. 18 (25-31 Oct 2003) open
</option>
<option value="accepted">Accepted Papers</option>
.......
</select> <input type="submit" value="Go">
</form>

concerning the <option value="...">, I don't know in advance the
value, only that I need the DEFAULT one (I believe that's the one
identified by "selected")

I know it's a mess, but can some good soul help me on this?

Thanks!


Alessandro Magni
 
B

Ben Morrow

I fear I don't understand correctly the method query_form in URI::URL
(and perldoc didnt help so much).

At least my version of LWP says that URI::URL has been superceded by
URI.
I need to access a page that has to be obtained by GET method in a
form.
I found that simply I can use
my $url = url($address);
$url->query_form(key1 => value1, ...);
$content = get($url);

but...

1st, I didnt understand how to point query_form to the right form if
the page contains many: by which keyword do I identify it?

The url given should be that which the form is *submitted* to: i.e. in
the example below you would use
my $url = url("http://link.aps.org/newfind/");
..
2nd, I don't understand the values to insert in query_form

These would be the input from the form, so again with the example
below you would have
$url->query_form(jrnl => 'prl', issue => 'v91i18');
.. Working out that you need 'v91i18' is of course a problem... :)

I would recommend you try using WWW::Automate, which may make your
life rather easier.
Practically, I'm trying to automate the download of the current issue
of PRL at http://prl.aps.org/, where I have:

<b>Recent and Future Issues</b><form method="GET"
action="http://link.aps.org/newfind/">
<input type="hidden" name="jrnl" value="prl">
<p><select name="issue" size="1">
<option value="v91i18"selected>Vol. 91, No. 18 (25-31 Oct 2003) open
</option>
<option value="accepted">Accepted Papers</option>
......
</select> <input type="submit" value="Go">
</form>

concerning the <option value="...">, I don't know in advance the
value, only that I need the DEFAULT one (I believe that's the one
identified by "selected")

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top