Merdinus wrote:
> 
> The webpage is at:  http://patft.uspto.gov/netahtml/PTO/srchnum.htm
> The submit form is submitting all the hidden variables in the webpage
> as well as a 7 digit number for a patent (ex. 7123456).  To gather
> info, after the call to "submit_form" I've edited the code to I've
> printed $mech->uri() to a file.  I then copied and pasted that string
> into a browser and the browser (IE7) happily gets redirected on, so it
> seems that submit_form is bringing me from the "start" webpage to the
> "middle" webpage, but then it's not carrying me on to the final
> webpage.
> 
> I could have sworn I've tried the $mech->redirect_ok() and got an
> error - some error deep in the code (i.e. below my code and in the
> perl code underneath).  But maybe I did it wrong, who knows.  Sorry I
> can't be more specific about this attempt, the code I put together is
> at work and I can't access it.  Tomorrow (Sunday the 10th) I'll try to
> rewrite all the code on this computer for debugging - shouldn't be too
> hard, there wasn't much.
> 
> Final piece of info:  I downloaded my perl executable from ActiveState
> (sometime last week, and I downloaded the most recent version
> available) - if that info means anything of importance.
> 
> Thanks again for the replies and any help is much appreciated.

The intermediate page uses a meta refresh, meaning that the destination URL is
in a <meta> tag, which WWW::Mechanize doesn't follow. Fortunately, recent
versions of WWW::Mechanize include such a redirect in the list of links for a
page, so it can be accessed by a call to

  $mech->follow_link(tag => 'meta');

A short, complete program to display the patent you mentioned is below. I am
using WWW::Mechanize version 1.34 and HTML::TreeBuilder version 3.23, although
the latter is only necessary for stripping the text out of the HTML on the last
line.

HTH,

Rob


use strict;
use warnings;

use WWW::Mechanize;

my $mech = WWW::Mechanize->new;

$mech->get('http://patft.uspto.gov/netahtml/PTO/srchnum.htm');
print $mech->title, "\n";

$mech->submit_form(
  with_fields => {TERM1 => 7123456},
);
print $mech->title, "\n";

$mech->follow_link(tag => 'meta');
print $mech->title, "\n";
print $mech->content(format => 'text');

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to