⬆️ ⬇️

Automatic status update VKontakte

I bring to your attention a small script to automatically update the status on the social network VKontakte. The script was written in half an hour, nothing complicated in it. The impetus for writing was the desire to indulge, a couple more interesting ideas arose in the process, which I do not plan to implement, maybe I can bring some thought and I will be glad. We will not rummage, get down to business.



And yes, I forgot to say, this is Perl. If there is a desire, you can easily repeat it in your favorite language.

#!/usr/bin/perl



print "Content-type:text/html\n\n" ;



#

require LWP::UserAgent;

use HTTP::Cookies;

use Encode;



#

$email = "name\@server.ru" ;

$password = "mypassword" ;

$path = "/home/anton/www/site.ru/cgi" ;



#

open (FILE, "$path/num.txt" );

$num = <FILE>;

close (FILE);



my $ua = LWP::UserAgent-> new ;

$ua->timeout(10);

$ua->agent( 'Mozilla/5.0' );

$ua->env_proxy;



# cookies

$cookies= new HTTP::Cookies(file=> '$path/cookies.dat' ,autosave=>1);

$ua->cookie_jar($cookies);



#

$loginpage = "http://vkontakte.ru/login.php?email=$email&pass=$password" ;

$response = $ua-> get ($loginpage);

$page = $response->content;



# activityhash

$ah = $1 if $page =~ m/<input type= 'hidden' id= 'activityhash' value = '(.+)' >/;



#

$status = "L&M's status - #$num" ;

Encode::from_to($status, 'windows-1251' , 'utf-8' );



# POST-

$response = $ua->post

( 'http://vkontakte.ru/profile.php' ,

[

activityhash => $ah,

setactivity => $status

]

);



# ,

print $response->content;



#

$num++;



#

open (FILE, ">$path/num.txt" );

print FILE $num;

close (FILE);




* This source code was highlighted with Source Code Highlighter .




Then we add the script to the cron's schedule:

*/3 * * * * /home/anton/www/site.ru/cgi/test.pl >/dev/null





And we look at the results:

')





How to apply it? Here is what came to mind:

- get your friends who don't get out of VKontakte with their statuses :))

- in the random, choose from the file any quotes, anecdotes, whatever

- make a countdown, for example, “Before my birthday there are 3 days, 15 hours and 42 minutes”

- attract friends to any events, sites, etc.

- well, spammers, of course, can use hacked accounts to collect traffic



And of all these ideas, you can make a special service that will perform all these actions. I wonder if VKontakte has a limit on the number of status updates per day? I'll find out soon :)

Have a good evening.

Just for fun.

Source: https://habr.com/ru/post/67857/



All Articles