updated git and svn scripts
[xrzperl.git] / t.sina.com.cn
blob7fbd76fd259961c44410161a85000f82be0c42a7
1 #!/usr/bin/perl -w
2 # $Id$
3 use strict;
4 require v5.10.0;
5 our $VERSION = 'v0.1';
7 BEGIN
9 my $PROGRAM_DIR = $0;
10 $PROGRAM_DIR =~ s/[^\/\\]+$//;
11 $PROGRAM_DIR = "./" unless($PROGRAM_DIR);
12 unshift @INC,
13 map "$PROGRAM_DIR$_",qw{modules lib ../modules ..lib};
16 my %OPTS;
17 my @OPTIONS = qw/help|h|? version|ver edit-me manual|man/;
19 if(@ARGV)
21 require Getopt::Long;
22 require MyPlace::Usage;
23 Getopt::Long::GetOptions(\%OPTS,@OPTIONS);
24 MyPlace::Usage::Process(\%OPTS,$VERSION);
26 else
28 require MyPlace::Usage;
29 MyPlace::Usage::PrintHelp();
32 die("This program doesn't work.\n");
33 my $url = shift;
34 die("Usage:$0 url\n") unless($url);
36 use MyPlace::Curl;
37 use URI::Escape;
38 sub _E {
39 my @o = @_;
40 my @r;
41 foreach (@o) {
42 tr/a-zA-Z#/n-za-mN-ZA-M@/;
43 push @r,$_;
45 return @r;
48 my $COOKIE_FILENAME = $ENV{'HOME'} . "/.myplace_curl.cookie";
49 my $CURL = MyPlace::Curl->new;
50 $CURL->set("cookie",$COOKIE_FILENAME);
51 $CURL->set("cookie-jar",$COOKIE_FILENAME);
52 $CURL->set("user-agent","Mozilla/5.0");# (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3 Firefox/3.0.1");
54 my ($_U,$_P)=_E("keysha#tznvy.pbz","nofserrqbz");
55 my %POSTDATA = (
56 service=>"miniblog",
57 client=>"ssologin.js%28v1.3.9%29",
58 entry=>"miniblog",
59 encoding=>"utf-8",
60 gateway=>"1",
61 savestate=>"7",
62 useticket=>"0",
63 from=>'',
64 url=>uri_unescape("http%3A%2F%2Ft.sina.com.cn%2Fajaxlogin.php%3Fframelogin%3D1%26callback%3Dparent.sinaSSOController.feedBackUrlCallBack"),
65 returntype=>"META",
67 $POSTDATA{_E("hfreanzr")}=$_U;
68 $POSTDATA{_E("cnffjbeq")}=$_P;
69 my $LOGINURL='http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.9)';
71 #die(join(" ",_E("user","name","pass","word")));
72 #hfre anzr cnff jbeq
74 $CURL->set('referer',$url);
75 my ($exit_code,$data) = $CURL->get($url);
76 if(!$exit_code == 0) {
77 print STDERR "Error when retriving '$url',\n";
79 elsif($data =~ /;return false;">登录<\/a>/) {
80 print STDERR "Trying to login first [$LOGINURL]...\n";
81 $CURL->set('location');
82 ($exit_code,$data) = $CURL->post($LOGINURL,$url,%POSTDATA);
83 ($exit_code,$data) = $CURL->get(uri_unescape('http%3A%2F%2Ft.sina.com.cn%2Fajaxlogin.php%3Fframelogin%3D1%26callback%3Dparent.sinaSSOController.feedBackUrlCallBack?retcode=6102'));
84 print STDERR "Reloading [$url]...\n";
85 ($exit_code,$data) = $CURL->get($url);
86 print $data;
88 else {
89 # print $data;
90 print 'OK',"\n";
94 __END__
96 =pod
98 =head1 NAME
100 t.sina.com.cn - PERL script
102 =head1 SYNOPSIS
104 t.sina.com.cn [options] ...
106 =head1 OPTIONS
108 =over 12
110 =item B<--version>
112 Print version infomation.
114 =item B<-h>,B<--help>
116 Print a brief help message and exits.
118 =item B<--manual>,B<--man>
120 View application manual
122 =item B<--edit-me>
124 Invoke 'editor' against the source
126 =back
128 =head1 DESCRIPTION
130 ___DESC___
132 =head1 CHANGELOG
134 2010-08-14 xiaoranzzz <xiaoranzzz@myplace.hell>
136 * file created.
138 =head1 AUTHOR
140 xiaoranzzz <xiaoranzzz@myplace.hell>
142 =cut