80degreez has asked for the wisdom of the Perl Monks concerning the following question:
no this is not for spam, it's just the way im attempting to familiarize myself with perl pattern matching. Logs in correctly, fetches page correctly, doesn't match/parse links correctlyuse strict; use WWW::Mechanize; use HTTP::Cookies; my $mech = WWW::Mechanize->new( agent =>"Mozilla/5.0 (X11; U; Li +nux i686; en-US; rv:1.7) Gecko/20040918 Firefox/0.9.3 "); my $usr = "80degreez\@gmail.com"; my $pw = "mypw"; my $currPage = 1; my $numPro = 0; my $loopa = 0; my $fn = 2; my $proList = ">>profiles.out"; open (OUT, ">>file.dump" ); $mech->get("http://indiecharts.com/"); $mech->cookie_jar( HTTP::Cookies->new() ); if( $mech->content() =~ /<form Method="Post" action="login.asp"> / ){ $mech->form_number($fn); $mech->field( UserName => $usr ); $mech->field( Password => $pw ); $mech->submit(); if ($mech->success() ) { if ( $mech->content() =~ /Pick your IndieCharts Name/ ) { print "User $usr logged in successfully!\n" ; do { $mech->get("http://indiecharts.com/indie_Music +_Artists.asp?Keyword=&Page=$currPage&butname="); my @profiles = $mech->find_all_links( t +ext_regex => qr/^d{9}$/ ); chomp @profiles; foreach my $parse (@profiles) { if (@profiles){ $numPro++; open (OUT, $proList) || p +rint "cant open profiles file!"; print OUT "$parse\n"; } } print "$currPage $numPro\n\n"; $currPage++; } while ( $currPage <= 500 ); } else { print " User $usr was unable to log in successfully!\n"; } } } else { print $mech->content; } close(OUT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Page Scraping
by kyle (Abbot) on May 01, 2007 at 20:37 UTC | |
|
Re: Page Scraping
by akho (Hermit) on May 01, 2007 at 20:28 UTC | |
|
Re: Page Scraping
by akho (Hermit) on May 01, 2007 at 20:44 UTC | |
by 80degreez (Initiate) on May 01, 2007 at 21:14 UTC | |
by akho (Hermit) on May 01, 2007 at 21:18 UTC | |
by shigetsu (Hermit) on May 01, 2007 at 21:36 UTC | |
by akho (Hermit) on May 02, 2007 at 08:19 UTC |