Skip Menu |

This queue is for tickets about the WWW-Myspace CPAN distribution.

Report information
The Basics
Id: 35275
Status: resolved
Priority: 0/
Queue: WWW-Myspace

People
Owner: Nobody in particular
Requestors: theartofweb [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: RE: friends_from_profile only returns the first page of results
Date: Tue, 22 Apr 2008 01:53:40 +0200
To: <bug-www-myspace [...] rt.cpan.org>, <grantg [...] cpan.org>
From: THEARTOFWEB <theartofweb [...] hotmail.com>
I have just come up with something to get all friends, it works great yet it takes a lot to get, say, 100000 friend ids: #!/usr/bin/perl use strict; use warnings; my $total_pages = $friend_id_has_x_friends / 40; my $friend_id = 12345; my @friendids = &_get_all_friends( $friend_id, $total_pages ); sub _get_all_friends ($$) { use LWP::UserAgent; my $friend_id = shift; my $total_pages = shift; foreach my $page ( 1 .. $total_pages ) { my $ua = LWP::UserAgent->new; $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)'); my $url = 'http://friends.myspace.com:80/index.cfm?fuseaction=user.viewfriends2&friendID=' . $friend_id . '&p=' . $page; my $res = $ua->get($url); my $html; my @friendids; if ($res->is_success) { $html = $res->content; } else { die $res->status_line; } while ( $html =~ //g ) { push @friendids,$1; } } my %uniq; my @newfriendids = grep { $uniq{$_}++ == 0 } @friendids; return @newfriendids; } __END__; so, how about that? Show quoted text
_________________________________________________________________ Racconta le tue emozioni sul blog! http://home.services.spaces.live.com/
Subject: Re: [rt.cpan.org #35275] RE: friends_from_profile only returns the first page of results
Date: Mon, 21 Apr 2008 18:12:19 -0700
To: bug-WWW-Myspace [...] rt.cpan.org
From: Grant Grueninger <grantg [...] spamarrest.com>
Hi Steven, Thanks for working on the code. To include it in the module though I need a patch, and it needs to use the methods in WWW::Myspace to access the site (i.e. get_page, etc). See the existing get_friends method for an example. I don't think the way you're accessing the friend page URL will work unless myspace has really simplified the way they handle paging since the last time I looked at it. Take a look at get_friends and hopefully you'll be able to patch it. :) (See the "CONTRIBUTING" section at the bottom of the WWW::Myspace docs for how to submit a patch). Grant On Apr 21, 2008, at 5:57 PM, THEARTOFWEB via RT wrote: Show quoted text
> > Mon Apr 21 20:57:28 2008: Request 35275 was acted upon. > Transaction: Ticket created by theartofweb@hotmail.com > Queue: WWW-Myspace > Subject: RE: friends_from_profile only returns the first page of > results > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: theartofweb@hotmail.com > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=35275 > > > > > I have just come up with something to get all friends, it works > great yet it takes a lot to get, say, 100000 friend ids: > > > #!/usr/bin/perl > > use strict; > use warnings; > > my $total_pages = $friend_id_has_x_friends / 40; > my $friend_id = 12345; > > my @friendids = &_get_all_friends( $friend_id, $total_pages ); > > sub _get_all_friends ($$) > { > use LWP::UserAgent; > > my $friend_id = shift; > my $total_pages = shift; > > foreach my $page ( 1 .. $total_pages ) > { > my $ua = LWP::UserAgent->new; > $ua->agent('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT > 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322)'); > my $url = 'http://friends.myspace.com:80/index.cfm?fuseaction=user.viewfriends2&friendID=' > . $friend_id . '&p=' . $page; > my $res = $ua->get($url); > my $html; > my @friendids; > > if ($res->is_success) > { > $html = $res->content; > } else { > die $res->status_line; > } > > while ( $html =~ //g ) > { > push @friendids,$1; > } > > } > > my %uniq; > my @newfriendids = grep { $uniq{$_}++ == 0 } @friendids; > > return @newfriendids; > } > __END__; > > so, how about that? > _________________________________________________________________ > Racconta le tue emozioni sul blog! > http://home.services.spaces.live.com/ >
-- Grant Grueninger grantg@spamarrest.com
Fixed in 0.79