Created
April 26, 2011 04:00
-
-
Save jjjjeeffff/941770 to your computer and use it in GitHub Desktop.
delete facebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use WWW::Mechanize; | |
use HTTP::Cookies; | |
use HTML::Parser; | |
use HTML::TagParser; | |
my $username = "PUT YOUR USERNAME HERE, escape the @ with \@, so me\@me.com"; | |
print $username; | |
my $password = "PUT YOUR PASSWORD HERE"; | |
print $password; | |
my $mech = WWW::Mechanize->new(); | |
$mech->agent_alias('Linux Mozilla'); | |
$mech->cookie_jar( HTTP::Cookies->new() ); | |
$mech->post( | |
"https://login.facebook.com/login.php?m&next=http://m.facebook.com/minifeed.php", | |
{ email => $username, pass => $password } | |
); | |
my $test = $mech->content(); | |
$mech->content() =~ /url=(.*?)"/; | |
my $newurl = $1; | |
$mech->get($newurl); | |
my $html = $mech->content(); | |
my $parser = HTML::Parser->new( api_version => 3, | |
start_h => [\&start, "tagname, attr"], | |
marked_sections => 1, | |
); | |
my @links; | |
sub start { | |
my ( $tagname, $attr ) = @_; | |
if ($tagname eq "a") { | |
push @links, $attr->{href}; | |
} | |
} | |
$parser->parse($html); | |
$parser->eof; | |
foreach $link (@links) { | |
if ( $link =~ /delete.php/ ) { | |
print $link; | |
$mech->get( "http://m.facebook.com" . $link ); | |
$html_p = HTML::TagParser->new( $mech->content() ); | |
@elem = $html_p->getElementsByTagName("form"); | |
$action = $elem[0]->getAttribute("action"); | |
@elem = $html_p->getElementsByAttribute( "name", "fb_dtsg" ); | |
$fb_dtsg = $elem[0]->getAttribute("value"); | |
@elem = $html_p->getElementsByAttribute( "name", "post_form_id" ); | |
$ministory_key = $elem[0]->getAttribute("value"); | |
@elem = $html_p->getElementsByAttribute( "name", "charset_test" ); | |
$story_type = $elem[0]->getAttribute("value"); | |
print "Deleting facebook wall post: $ministory_key.. "; | |
$mech->post( | |
"http://m.facebook.com" . $action, | |
{ | |
fb_dtsg => $fb_dtsg, | |
post_form_id => $ministory_key, | |
charset_test => $story_type | |
} | |
); | |
print "sleep"; | |
sleep(5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment