Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Checkboxes with the same name

by seaver (Pilgrim)
on Sep 27, 2004 at 15:44 UTC ( [id://394210]=note: print w/replies, xml ) Need Help??


in reply to Re: Checkboxes with the same name
in thread Checkboxes with the same name

ikegami

Thanks for your reply, it was certainly what I was looking for

However, I cant seem to get the right response. I used HTTP::Request::Form to print out the URL, with all the fields I knew I needed to fill, and used it as a guide.

I've replaced all '&' with '\n' here for easier reading for the encoded URL string from HTTP::Request::Form:

Func=Search Form=HomePage SID=QVgragrh%40WcAAB5MdZ8 topic=Enter+a+topic editions=H editions=H editions=H Period=Year+Range week_selection=LatestWeek years=2004 start_year=1955 end_year=2004 General+Search.x=2 General+Search.y=2
And the code I'm using to try and replicate this, except for the editions, where Im following your example, is:
$res = $ua->request(POST 'http://wos4.isiknowledge.com/CIW.cgi', [Func => 'Search', Form => 'HomePage', SID => $sid, topic => 'Enter+a+topic', editions => qw[(D A H)], Period => 'Year Range', week_selection => 'LatestWeek', years => 2004, start_year => 1955, end_year => 2004, 'General Search.x' => 2, 'General Search.y' => 2]);
However, this is not producing the right response, and the HTTP::Request::Form method actually produced a better response, something is wrong with my attempt at using HTTP::Request::Common, but I dont know what it is that I'm doing wrong?

Thanks for any help
Sam </code>

Replies are listed 'Best First'.
Re^3: Checkboxes with the same name
by ikegami (Patriarch) on Sep 27, 2004 at 16:09 UTC

    I'm confused as to why you're talking about HTTP::Request::Form again, since we established there was a bug in it.

    I ran a few tests:

    use URI; my $uri = URI->new("http://www.domain.com/"); $uri->query_form( editions => [qw( D A H )], ); print($uri->as_string(), "\n"); # http://www.domain.com/?editions=D&editions=A&editions=H

    so far so good

    use LWP; use HTTP::Request::Common; $request = POST 'http://www.domain.com/', [ editions => [qw( D A H )], ]; print($request->as_string(), "\n"); # POST http://www.domain.com/ # Content-Length: 54 # Content-Type: application/x-www-form-urlencoded # # editions=D&editions=A&editions=H

    Working great!

    >perl -MURI -le "print $URI::VERSION" 1.19 >perl -MLWP -le "print $LWP::VERSION" 5.64

    I'm not sure what you're trying to do. WWW::Mechanize might be of interest to you.

      OK, here's the problem

      Below I have two '$request->as_string()' each identical and yet from different sources:

      my $f = HTTP::Request::Form->new($forms[0], $wosURL); my $boo = $f->press("General Search"); print $boo->as_string;
      outputs:
      POST http://wos4.isiknowledge.com/CIW.cgi Content-Length: 227 Content-Type: application/x-www-form-urlencoded Func=Search&Form=HomePage&SID=QVhJgArh%40WcAACmJAys&topic=Enter+a+topi +c&editions=H&editions=H&editions=H&Period=Year+Range&week_selection=L +atestWeek&years=2004&start_year=1955&end_year=2004&General+Search.x=2 +&General+Search.y=2
      and this one
      my $request = POST 'http://wos4.isiknowledge.com/CIW.cgi', [Func => 'Search', Form => 'HomePage', SID => $sid, topic => 'Enter a topic', editions => [qw( D A H )], Period => 'Year Range', week_selection => 'LatestWeek', years => 2004, start_year => 1955, end_year => 2004, 'General Search.x' => 2, 'General Search.y' => 2]; print $request->as_string();
      outputs:
      POST http://wos4.isiknowledge.com/CIW.cgi Content-Length: 227 Content-Type: application/x-www-form-urlencoded Func=Search&Form=HomePage&SID=QVhJfQrh%40WcAABfkZ3c&topic=Enter+a+topi +c&editions=D&editions=A&editions=H&Period=Year+Range&week_selection=L +atestWeek&years=2004&start_year=1955&end_year=2004&General+Search.x=2 +&General+Search.y=2
      Because of the bug in HTTP::Request::Form, when I send the first request, the resulting web-page lists the three same editions, BUT if I send using the request I made on my own, the resulting web-page doesnt list ANY edition.

      This tells me there's something different between the request object generated by HTTP::Request::Form, and my own request object, and I'm not sure what it is??

      Thanks
      Sam

      ps I'll check out Mechanize, thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://394210]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found