My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!c:/Perl/bin/perl
# (c) 2008, nizamov@inbox.ru

use strict;
use LWP;
use HTTP::Cookies;
use HTTP::Headers::Util qw(split_header_words);
use encoding "ru_RU.CP1251";

my $email = '';
my $pass = '';

my $ua = LWP::UserAgent->new;
my $cookie_jar = HTTP::Cookies->new;
$ua ->cookie_jar($cookie_jar);
$ua->agent("Calendar/0.1 (Linux; U; Windows NT 5.1; ru) Import");
open (VKCALICS, ">>:utf8", "vk.events.ics");
print VKCALICS "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN";
&set_cookies($email,$pass);
&calendar();
print VKCALICS "\nEND:VCALENDAR";
close (VKCALICS);


# --------------------------------------------------------------------
sub set_cookies
# àâòîðèçàöèÿ
{
my $email = $_[0];
my $pass = $_[1];
my $url = "http://vkontakte.ru/login.php";
my $res = $ua->post(
$url,
['email' => $email,
'pass' => $pass
]);
my $cookie = $res->header("Set-Cookie");
$cookie_jar->extract_cookies( $res );
}

# --------------------------------------------------------------------
sub calendar
# âûâîä ñòðàíèöû êàëåíäàðåé çà âñå ìåñÿöû
{
my $cookie=$_[0];
foreach my $month (1..12){
my $url = "http://vkontakte.ru/calendar_ajax.php?month=$month&year=2008";
my $req = new HTTP::Request(
'GET' => "$url",
new HTTP::Headers(
'Host' => 'vkontakte.ru',
'User-Agent' => 'Calendar/0.1 (Linux; U; Windows NT 5.1; ru) Gecko Mozilla',
'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Language' => 'ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3',
'Accept-Encoding' => 'gzip,deflate',
'Accept-Charset' => 'windows-1251,utf-8;q=0.7,*;q=0.7',
'Keep-Alive' => '300',
'Connection' => 'keep-alive',
'Content-Type' => 'application/x-www-form-urlencoded; charset=windows-1251',
'Referer' => 'http://vkontakte.ru/events.php?act=calendar',
'Content-Length' => '0',
'Pragma' => 'no-cache',
'Cache-Control' => 'no-cache'
));
$cookie_jar->add_cookie_header($req);
my $res = $ua->request($req);
my $cont = HTTP::Message->new( $res->headers, $res->content );
if ($res->is_success) {
my $cal_one = $cont->decoded_content( 'charset' => "none" );
&parce_cal_all($cal_one,$month);
}
else {
print STDERR $res->status_line, "\n";
}
}
}

# --------------------------------------------------------------------
sub parce_cal_all
# ïàðñèì êàëåíäàðü
{
my $cal_one=$_[0];
my $month=$_[1];
printf VKCALICS "\nBEGIN:VEVENT\nSUMMARY:$5\nRRULE:FREQ=YEARLY;INTERVAL=1\nDTSTART;VALUE=DATE:2008%02d%02d\nDTEND;VALUE=DATE:2008%02d%02d\nCATEGORIES:Äíè ðîæäåíèÿ\nURL:http://vkontakte.ru/$2\nDESCRIPTION:Äàòà Ðîæäåíèÿ: %02d.%02d.".(2008-$6)."\\nÔîòî:\n $4\nEND:VEVENT"
, $month, $1, $month, ($1+1), $1, $month
while $cal_one =~ /<div class='calPic' id='([^>]*?)pic0' ><a href='([^>]*?)'>([^>]*?)trailOn\('([^>]*?)','([^>]*?)\s+\((.*?)\)'/g;
}

Change log

r8 by alex.nizamov on Dec 14, 2008   Diff
[No log message]
Go to: 
Sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 2911 bytes, 87 lines
Powered by Google Project Hosting