simple perl script for automatic form submission.


S

sam

Hi,

I m not a perl expert.
I would like to write a simple perl script to automatically login my
email account that hosted by a commerical webmail server.

Is there any sample script I can follow?

Thanks
Sam
 
Ad

Advertisements

W

wana

sam said:
Hi,

I m not a perl expert.
I would like to write a simple perl script to automatically login my
email account that hosted by a commerical webmail server.

Is there any sample script I can follow?

Thanks
Sam

try LWP::UserAgent from CPAN (actually it already came with my Linux
installation).

I just started playing with it and was able to get into a site I created but
I then tried submitting data to some commercial sites and my script was
rejected with the same form data I was able to submit legitimately through
their webpage. I am not sure how to 'trick' the site into not knowing if
it is a web browser or a Perl script trying to submit form data. I can get
as far as looking at the html source, finding the form, identifying POST or
GET, and finding the field names.

Since I was able to log into my own homemade site, I know it works and is
not a Perl issue. 'Perl Cookbook' has a brief section on LWP and there is
probably more in Lincoln Stein's book on Perl networking.

wana
 
W

wana

Andrew said:
Lots of 'dirty' work may be done by HTML::Form
module. You won't need to find all hidden etc. fields in forms,
this module will do it for you.

Regards,
Andrew

Thanks for the tip!

It turns out that 'Network Programming with Perl' by Lincoln Stein does have
a chapter (9) on LWP. He says:

For an exhaustive treatment, see LWP's POD documentation,
or the excellent, but now somewhat dated 'Web Client
Programming with Perl [Wong 1999].

I will definitely take a look at HTML::Form now. Thanks.

wana
 
A

Andrew Tkachenko

Lots of 'dirty' work may be done by HTML::Form
module. You won't need to find all hidden etc. fields in forms,
this module will do it for you.

Regards,
Andrew


wana wrote on 12 ÐоÑбрь 2004 11:59:
 
W

wana

wana said:
try LWP::UserAgent from CPAN (actually it already came with my Linux
installation).

I just started playing with it and was able to get into a site I created
but I then tried submitting data to some commercial sites and my script
was rejected with the same form data I was able to submit legitimately
through
their webpage. I am not sure how to 'trick' the site into not knowing if
it is a web browser or a Perl script trying to submit form data. I can
get as far as looking at the html source, finding the form, identifying
POST or GET, and finding the field names.

Since I was able to log into my own homemade site, I know it works and is
not a Perl issue. 'Perl Cookbook' has a brief section on LWP and there is
probably more in Lincoln Stein's book on Perl networking.

wana

Turns out I simply had to include a single hidden field to make things work.
Wow what a poor hacker deterrent, using a hidden field.

wana
 
W

wana

wana said:
try LWP::UserAgent from CPAN (actually it already came with my Linux
installation).

I just started playing with it and was able to get into a site I created
but I then tried submitting data to some commercial sites and my script
was rejected with the same form data I was able to submit legitimately
through
their webpage. I am not sure how to 'trick' the site into not knowing if
it is a web browser or a Perl script trying to submit form data. I can
get as far as looking at the html source, finding the form, identifying
POST or GET, and finding the field names.

Since I was able to log into my own homemade site, I know it works and is
not a Perl issue. 'Perl Cookbook' has a brief section on LWP and there is
probably more in Lincoln Stein's book on Perl networking.

wana

I just figured out how to do a Google search from a Perl script:

#!/usr/bin/perl
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
$q = $ARGV[0];
$q =~ s/\s/+/g;
$h =
"http://www.google.com/search?hl=en&ie=ISO-8859-1&q=$q&btnG=Google+Search";
$ua->agent("Mozilla/5.0 (compatible; Konqueror/3.1; Linux 2.4.20)");
$resp = $ua->get($h);
$content = $resp->content;
print "$content\n";

Like usual, maybe not the best way, but it does work. This is really cool!

Couldn't anyone make a search engine 'powered by Google' using something
like this? I thought it would be neat to include some dynamic Google
search and/or news content on my personal website, but I don't know if it's
legal. But, then again, don't they reprint other people's material in
their searches? Sorry, I'm getting off topic, but the implications for a
newbie like me are huge.

wana
 
Ad

Advertisements


Top