Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

initself's scratchpad

by initself (Monk)
on Dec 09, 2005 at 00:33 UTC ( [id://515429]=scratchpad: print w/replies, xml ) Need Help??

Result of submit()
POST http://browseusers.myspace.com/Browse/Browse.aspx?MyToken=6326973 +04010526126 Content-Length: 226 Content-Type: application/x-www-form-urlencoded __EVENTTARGET=update&__EVENTARGUMENT=&__VIEWSTATE=&Page=1&Scope=scopeF +ullNetwork&Gender=genderWomen&minAge=18&maxAge=100&country=US&zipRadi +us=Any&zipCode=&showHasPhotoOnly=on&showNamePhotoOnly=on&SortBy=sortB +yLastLogin&update= POST http://browseusers.myspace.com/Browse/Browse.aspx?MyToken=6326973 +04012313950 Content-Length: 221 Content-Type: application/x-www-form-urlencoded __EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&Page=75&Scope=scopeFullNe +twork&Gender=genderWomen&minAge=18&maxAge=100&country=US&zipRadius=An +y&zipCode=&showHasPhotoOnly=on&showNamePhotoOnly=on&SortBy=sortByLast +Login&update=
looks good to me
#!/usr/bin/perl use strict; use warnings; use CGI ':standard'; use MySpace::Configuration; use MySpace::MySpaceUserAgent; use HTML::Form; use HTML::LinkExtor; # Load Configuration File my $configuration = MySpace::Configuration->new("config/myspace_mikeba +as.conf", "config"); # Create Authenticated MySpace Browser my $browser = MySpace::MySpaceUserAgent->new( cookies_dir => $configuration->cookies_dir, login_url => $configuration->login_url, username => $configuration->username, password => $configuration->password ); my $browse_url = 'http://browseusers.myspace.com/Browse/Browse.aspx'; my $response = $browser->get($browse_url); my @forms = HTML::Form->parse($response); # Pull ACTION out of JavaScript function my $content = $response->content; $content =~ m{document\.frmBrowse\.action = "(.*?)"}; my $action_url = "http://browseusers.myspace.com/Browse/" . "$1"; $forms[1]->action($action_url); my $action = $forms[1]->action; # Get Form Elements my $zipRadius = $forms[1]->find_input("zipRadius", "option"); + my $zipCode = $forms[1]->find_input("zipCode", "text"); my $minAge = $forms[1]->find_input("minAge", "option"); my $maxAge = $forms[1]->find_input("maxAge", "option"); my $Scope = $forms[1]->find_input("Scope", "radio"); my $showHasPhotoOnly = $forms[1]->find_input("showHasPhotoOnly", "che +ckbox"); my $showNamePhotoOnly = $forms[1]->find_input("showNamePhotoOnly", "ch +eckbox"); # Get Hidden Values my $update = $forms[1]->find_input("update", "submit"); my $__EVENTTARGET = $forms[1]->find_input("__EVENTTARGET"); my $Page = $forms[1]->find_input("Page"); # Assign Values $zipRadius->value("Any"); $zipCode->value(""); $minAge->value("18"); $maxAge->value("100"); $Scope->value("scopeFullNetwork"); # [scopeFullNetwork|*scop +eMyFriends] $showHasPhotoOnly->value("on"); $showNamePhotoOnly->value("on"); # Assign Hidden Values $update->value(""); $__EVENTTARGET->value("update"); $Page->value("1"); # Dump Form #print $forms[1]->dump; # Update Form my $filled_out_request = $forms[1]->click; #print $filled_out_request->as_string; $response = $browser->request($filled_out_request); # Parse Content For Links my $p = HTML::LinkExtor->new; $p->parse($response->content); my @links = $p->links; push my @urls, map {$_->[2]} @links; # Remove Duplicates my %saw; @saw{@urls} = (); my @unique_urls = sort keys %saw; # Parse Urls my @pages; foreach my $sorted_url (@unique_urls) { # Friend Urls if ($sorted_url =~ m{http://profile.myspace.com/index.cfm\?fuseactio +n=user.viewProfile&friendID=(.*?)&}) { my $friend_id = $1; #print "$friend_id\n"; } # Page Urls if ($sorted_url =~ m{javascript:GotoPage\((.*?)\)\;}) { my $page = $1; push(@pages, $page); } } # Get Last Page my $lastpage = pop @pages; #print "$lastpage\n"; # Attempt to emulate this: #function GotoPage(page) { # document.frmBrowse.Page.value = page; # document.frmBrowse.action = "Browse.aspx?MyToken=6326971945227880 +21"; # document.frmBrowse.submit(); # return true; #} $content = $response->content; $content =~ m{document\.frmBrowse\.action = "(.*?)"}; $action_url = "http://browseusers.myspace.com/Browse/" . "$1"; $forms[1]->action($action_url); $action = $forms[1]->action; $__EVENTTARGET->value(""); $Page->value("$lastpage"); $filled_out_request = $forms[1]->click; # print $filled_out_request->as_string; # Looks like this # __EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&Page=75&Scope=scopeFull +Network&Gender=genderWomen&minAge=18&maxAge=100&country=US&zipRadius= +Any&zipCode=&showHasPhotoOnly=on&showNamePhotoOnly=on&SortBy=sortByLa +stLogin&update= # # Which is identical to the Firefox Live HTTP Header.... $response = $browser->request($filled_out_request); $content = $response->content; print $content; # Page stays the same as the first page. What's wrong?
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-18 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found