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);
In reply to Page Scraping by 80degreez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |