Re: using WWW::Mechanize on activestate

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
On Fri, 20 Feb 2009 20:08:58 -0800, Tim Greer wrote:

Quoted text here. Click to load it

Thanks for your reply, Tim.

# url

use warnings;
use strict;
use diagnostics;

use HTML::TreeBuilder;
use LWP::Simple;
use LWP::UserAgent;
use WWW::Mechanize;

my $site_url = ' ';
my $url_args = 'advanced_search';
my $t = get "$site_url/$url_args" || "Problem";

my $tree = HTML::TreeBuilder->new_from_content($t);


my $g = 'comp.lang.perl.misc';
my $s = 'mechanize website';

# perl

You've helped me chase down one of these tags before, getting values in
entities similar to the following:

foreach my $elem ( $tree2->look_down('_tag', 'center') ) {
++ $i;
print "i is $i\n";
print "elem is $elem\n";

    print $elem->as_text(), "\n";

foreach my $elem ( $tree2->find_by_attribute('name', 'lat') ) {
print "****";
    print $elem->attr('value'), "\n";

The fields I want to populate are:
<input name="as_ugroup" size="40" type="text" value="" />

<input name="as_usubject" size="40"

I want to put $g into the group and $s in the subject.

Fishing for tips.
larry gates

echo "Congratulations.  You aren't running Eunice."
             -- Larry Wall in Configure from the perl distribution

Re: using WWW::Mechanize on activestate

Quoted text here. Click to load it

Expecting us to write your programs for you is going to be disappointing.

Read the documentation for the module you plan to use:

    perldoc WWW::Mechanize


        form_number => 3,
        fields      => {
            username    => 'mungo',
            password    => 'lost-and-alone',

Find out how to identify which form on the page to submit, set form_number
to the correct value, or use one of the other Mechanize methods for
identifying the form that you want to submit.

Replace the "username" and "password" fields in the
example code with "as_ugroup" and "as_usubject".

However, what you appear to be doing violates Google's ToS:

    you agree that when using the Service, you will not:
    use any robot, spider, site search/retrieval application, or other
    device to retrieve or index any portion of the Service or collect
    information about users for any unauthorized purpose;

So pick some other website that allows you to do what you
are attempting to do.

Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Site Timeline