sandwich vs Linux
fatsandwich
全部博文(161)
shell(4)
基础知识(3)
小白问题(1)
函数使用备忘(1)
Qt(1)
Django(2)
pure-ftpd(1)
netshare(1)
Junit(5)
语法(1)
Spring(7)
2011年(21)
2010年(33)
2009年(89)
2008年(18)
runhuayi
xincilia
lx121781
yongbinx
hbjxzhan
wangchen
wzhanggz
sj199132
cocoecel
分类:
2009-06-27 04:00:06
#!/usr/bin/perl -w # Twitter -> Xiaonei status sync tool. # Author: Feng Liu # Version: 1.0 # Date: Tue Apr 21 23:06:40 +0000 2009 use utf8; use Encode; use LWP::Simple; use HTML::Entities; ####################### Settings starts here ####################### # Set your base account information here. Don't show this to others! my $twitter_account = ''; my $xiaonei_email = ''; my $xiaonei_passwd = ''; # some machine's wget is too old, so you may need to rebuild a newer # version and indicate the path of your own wget here. my $wget_cmd = 'wget'; # The program needs a log file for keeping the time of your last # tweet. Otherwise you may get your xiaonei status updated to a same # tweet. So please keep this file! my $logfile = '/tmp/twxn.log'; ######################## Settings ends here ######################## my $twitter_url = '' . $twitter_account . '.xml'; my $statuses = get($twitter_url); my @lines = split /\n/, $statuses; my $latest_text = $lines[5]; my $latest_time = $lines[3]; if ($latest_text =~ /<text>(.*)<\/text>/) { $status = $1; }; $text = decode_entities($status); # If the log file doesn't exist, create a new one. if (!(-e $logfile)) { open LOG,"> /tmp/twxn.log" or die "ERROR: Cannot create log file."; close LOG; print "Created a new log file: $logfile\n"; } open LOG, "< $logfile" || die "ERROR: Cannot open log file!"; $last_time = <LOG>; close LOG; if ($last_time ne $latest_time) { my $login_cmd = $wget_cmd . ' --no-proxy -O xiaoneilogin.log --post-data="email=' . $xiaonei_email . '&password=' . $xiaonei_passwd . '&autoLogin=true" --keep-session-cookies --save-cookies=xiaoneicookie '; my $post_cmd = $wget_cmd . ' --no-proxy -O xiaoneipost.log --post-data="c=' . $text . '" --keep-session-cookies --load-cookies=xiaoneicookie --referer='; system($login_cmd); system($post_cmd); open LOG, "> $logfile" || die "ERROR: Cannot open log file!"; print LOG $latest_time; close LOG; }
上一篇:校内网发帖机in Python,请勿滥用
下一篇:python代码之登录校内,自动访问好友
登录 注册