#!/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 .
*/3 * * * * /home/anton/www/site.ru/cgi/test.pl >/dev/null
Source: https://habr.com/ru/post/67857/