On Mon, 17 Sep 2001, Ted Sung wrote:

> I want to be able programmatically to go to a web site, enter a value
> in one of the text boxes provided and hit submit and then have the
> returned page to parse through.  What is the simplest way to do this?
 
Assuming you're talking about a pre-existing page somewhere out on the web
already, go to that page & view the html source. Most likely there will be
a form structure, a submission method (put or get) and one or more input
elements. 

In the simplest case, if the form issues a GET request for just one field,
then it's constructing a http request something like this:

   GET http://site.com/cgi-bin/page.pl?text=Your%20text

So, all you have to do is copy that -- figure out what you want the input
text to be and GET it. 

    #!/bin/perl
    # getsitepage.pl
    use strict;
    use LWP::Simple;

    my $text = $ARGV[0];
    my $url  = "http://site.com/cgi-bin/page.pl?text=$text";;
 
    print (get $url);

And then run it as, for example:

    c:\perl\> perl getsitepage.pl "your text"

...and it will then dump out the resulting page. 

If you need to programmatically analyze both the submission page and the
result page, the work is a little bit harder, but still it's not so bad,
and the code above gives you the core idea. 

Check out _Web Client Programming with Perl_, available online for free at
<http://www.oreilly.com/openbook/webclient/>. 

Chapter five begins the discussion of what you're trying to do.
<http://www.oreilly.com/openbook/webclient/ch05.html>

The next chapter gives more complex examples, including a program that
periodically checks on the status of a package with FedEx:
<http://www.oreilly.com/openbook/webclient/ch06.html>



-- 
Chris Devers                     [EMAIL PROTECTED]


_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web

Reply via email to