CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
modifications to this perl script

 



soj
New User

Mar 30, 2006, 3:50 AM

Post #1 of 3 (1300 views)
modifications to this perl script Can't Post

i have this perl script which is basically a myspace friend adder, i was wondering if someone would be able to help me make it so it automatically bypasses CAPTCHA, the way it can do this is once it hits a CAPTCHA page, all you have to do is make the script send a message to the person and then myspace acts the same as if you were to put in the image verification code. I attempted to modify the code, but failed miserably as i am a PHP person, Perl is not my forte. I was wondering if anyone was willing to help me, i will add the original perl script to the page so u can check it out

thanks in advance

michael


Code
#!/usr/bin/perl -w 

# This code was developed by Eric Skiff (http://www.glitchnyc.com)
# Copyright (C) 2006 Eric Skiff
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.

# Purpose of GlitchCastFriendAdder : bulk-add friends to a myspace account
#
# History :
# . originally by Eric Skiff <GlitchCastFriendAdder a.t. Glitchnyc.com>
# . Version 1.2 by Eric Skiff, March 09, 2006
# fix syntax bug on line 79
# change submit22 to loginbutton
# .add support for firefox opening of captchas, proper
# .CSV files with linefeeds

use strict;
use WWW::Mechanize;
use HTML::TokeParser::Simple;
use Text::CSV;

#########################################
#Modify these values ####################

my $username = 'email@myspace.com';
my $password = 'myspace';
#firefox location is simply firefox on mac + linux. Uncomment the c:/
#to run on windows
my $firefoxExecutable = 'firefox'; #comment this line on windows
#my $firefoxExecutable = 'c:/progra~1/mozill~1/firefox.exe'; #uncomment this line on windows
####
#########################################
#Don't edit below this line unless you #
#know what you're doing #
#########################################

my $file = 'friendPagesToScrape.txt';



my $csv = Text::CSV->new();

open (CSV, "<", $file) or die $!;
open (textFile, ">scrapedFriendIDs.csv"); #the > means overwrite >> would be append
my $agent = WWW::Mechanize->new();
my $tag;
my $urlWithFriendID;
my $friendIdToAdd;
my $whereToSplit;
my %array;
my $key;
my $value;
my $i;
my $sleepTime = 7;
my $openLink;


###############################
print ("Open captchas in firefox?\n[y/N]");
$_ = <STDIN>;
if ( /[Yy]/ ){
$openLink = 1;
print ("\nLinks will be opened in firefox");
}
else {
$openLink = 0;
print ("\nLinks will not be opened");
}
###############################
print ("\n\nDEVELOPERS NOTE:I wrote this script to promote my podcast, The GlitchCast\n");
print ("Adding friends will take a while, so you'll need some good music while you work.\n");
print ("Okay if this script opens the GlitchCast page in firefox so you can listen to great\n");
print ("new indie and underappreciated music while you add?\n[y/N]");
$_ = <STDIN>;
if ( /[Yy]/ ){
system("$firefoxExecutable http://www.glitchnyc.com/GlitchCast &");
}
############################
#first we log in... hopefully this will store good stuff in the cookiejar
############################
$agent->get("http://www.myspace.com/?Mytoken=13BFE4B7-55AE-AE67-415379F323B47CBA19243938");
$agent->form_name("theForm");
$agent->field( "email", $username);
$agent->field( "password", $password );
$agent->click("loginbutton");
print textFile $agent->{content};
#sleep 2000;
############################
#now lets get some pages, and the friendIDs in them
############################

while (<CSV>) {
if ($csv->parse($_)) {
my @columns = $csv->fields();
foreach (@columns){
#print "Getting page: @columns[1]\n\n";
#$agent->get("@columns[$i]");
#there's only one field on each line
$agent->get("@columns[0]");
if ($agent->success()) {
#$agent->form(1);
#$agent->field("zip", @columns[1]);
print "\nGetting info for @columns[0]\n";
#$agent->click();

#DEBUG - this prints out everything we get on the retrieved page.
#print $agent->{content};
###########################
#now we want to scrape out all the friend IDs on the pages in the CSV file
my $stream = HTML::TokeParser::Simple->new(\$agent->{content});
while ($tag = $stream->get_tag("a")){
$_ = $tag->get_attr("href");
if ( /friend[iI][dD]/ ){
$urlWithFriendID = $_;
$whereToSplit = rindex($urlWithFriendID, "=") + 1;
$friendIdToAdd = substr($urlWithFriendID, $whereToSplit);
createPair($friendIdToAdd, "0");
}
} #done getting the friend IDs from that page

###########################
#After scraping the friend IDs out into the array, we're going to add all the friends.
#Here's an example of the syntax
#http://www.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=6840420
while (($key, $value) = each %array) {
$agent->get("http://www.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=$key");
#print "http://www.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=$key";
if ($agent->success()) {
print "Adding friend $key...";
#print textFile $agent->{content};
##############################
#should check for a captcha here
$_ = $agent->{content};
if ( /image.above/ ){
print "captcha detected. Go add a friend manually.\n";
print "Here's the current page:\n";
print "http://www.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=$key\n";
if($openLink == 1){
system("$firefoxExecutable http://www.myspace.com/index.cfm?fuseaction=invite.addfriend_verify\\\&friendID=$key");
}
print "Enter + to speed up, - to slow down, or a new # of seconds to sleep. \nJust press enter to continue at this speed \n";
$_ = <STDIN>;
if ( /\-/ ){
#slow things down by adding more sleep time
$sleepTime = $sleepTime + 1;
print "Slowing Down by 1 sec. sleepTime is now $sleepTime \n";
}
elsif ( /\+/ ){
#speed things up by reducing the sleep time
$sleepTime = $sleepTime - 1;
print "Speeding up by 1 sec. sleepTime is now $sleepTime \n";
}
elsif (/[0-9]+/){
#we got a number, take that as the new value
$sleepTime = $_;
print "New sleepTime set. sleepTime is now $sleepTime \n";
}
#now that the captcha has been human-entered, try this friendID again
$agent->reload();
}
$agent->form("addFriend");
$agent->submit();

####################
#DEBUG
#print textFile $agent->{content};
###############################
# report success here
$_ = $agent->{content};
if ( /email.has.been.sent/ ){
print "success\n";
sleep $sleepTime;
}
else{
print "Not Added. (possibly already a friend, esp if addFriend form was not found above)\n ";
}
}
delete($array{$key}); #remove the friendID we just added
};
} #end of the page full of friends
else {
print "$agent->{content};"
}
$i++;
} #Get next URL from CSV list
}#no more comma separated values to parse
} #no more file to read

sub createPair{
################
#just a small function to make working with arrays easier
my($key, $value) = @_ ;
$array{$key} = $value;
};



(This post was edited by soj on Mar 30, 2006, 10:21 PM)


KevinR
Veteran


Mar 30, 2006, 6:44 PM

Post #2 of 3 (1296 views)
Re: [soj] modifications to this perl script [In reply to] Can't Post

thanks for posting a real account name and password in your message.... Wink
-------------------------------------------------


soj
New User

Mar 30, 2006, 10:17 PM

Post #3 of 3 (1294 views)
Re: [KevinR] modifications to this perl script [In reply to] Can't Post

my bad, lol. all good now. so is anyone able to help me???

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives