Use perl to automatically delete your facebook wall posts!
by Lonnie on May.06, 2010, under Linux, Nerd Stuff, Programming
OK I won’t lie, this was cobbled together quickly .. and it will only delete so many at a time so you’ll need to run it a few times if you’ve got a lot of posts, I could make it so that it loops and deletes everything but I wanted to put it out there.
Use it at your own risk! if you get banned from facebook for automating something then that’s your own fault.. this is purely for educational purposes only and all that jazz =) *wink wink*
Continue on reading!..
This code will log you in, go to m.facebook.com/minifeed.php and pull a list of stories then will loop through and delete them with a 5 second rest between deletes.. (less obvious) .. it also pretends to be firefox.
This requires WWW::Mechanize, HTTP::Cookies, HTML::Parser and HTML::TagParser .. ENJOY!
#!/usr/bin/perl
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::Parser;
use HTML::TagParser;my $username = “user@domain.com”;
my $password = “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"], );
my @links;
sub start {
my ($tag, $attr) = @_;
if ($tag =~ /^a$/ and defined $attr->{href}) {
return
if ($attr->{href} =~ m!^http://! and $opts{r}); # exclude absolute url when -r
return
if ($attr->{href} !~ m!http://! and $opts{a});# exclude relative url when -a
push @links, $attr->{href};
}
}
$parser->parse($html);
$parser->eof;foreach $link (@links) {
if ($link =~ /delete.php/) {
$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”, “ministory_key” );
$ministory_key = $elem[0]->getAttribute(“value”);@elem = $html_p->getElementsByAttribute( “name”, “story_type” );
$story_type = $elem[0]->getAttribute(“value”);@elem = $html_p->getElementsByAttribute( “name”, “profile_id” );
$profile_id = $elem[0]->getAttribute(“value”);@elem = $html_p->getElementsByAttribute( “name”, “confirm” );
$confirm_id = $elem[0]->getAttribute(“value”);print “Deleting mini story key: $ministory_key..n”;
$mech->post(“http://m.facebook.com” . $action,
{fb_dtsg=>$username,
ministory_key=>$ministory_key,
story_type=>$story_type,
profile_id=>$profile_id,
confirm_id=>$confirm_id});
sleep(5);}
Incoming search terms:
- perl delete facebook
- facebook automatically deleting wall post
- how to delete your facebook wall
- friend list facebook perl
- how to auto delete wall post
- parse facebook wall
- $mech->cookie_jar
- perl facebook
- perl facebook post
- perl facebook search