您的位置:首页 > 编程语言 > Python开发

人人网自动登录脚本_python

2011-03-29 13:51 796 查看
import urllib,urllib2,cookielib
from BeautifulSoup import BeautifulSoup
myCookie = urllib2.HTTPCookieProcessor(cookielib.CookieJar())
openner = urllib2.build_opener(myCookie)

post_data = {'email':'ChenxofHit@gmail.com',
'password':'#¥#¥##¥#¥#¥',
'origURL':'http://www.renren.com/Home.do',
'domain':'renren.com'}
req = urllib2.Request('http://www.renren.com/PLogin.do', urllib.urlencode(post_data))
html_src = openner.open(req).read()
parser = BeautifulSoup(html_src)

article_list = parser.find('div','feed-list').findAll('article')
for my_article in article_list:
state = []
for my_tag in my_article.h3.contents:
factor = my_tag.string
if factor != None:
factor = factor.replace(u'\xa0','')
factor = factor.strip(u'\r\n')
factor = factor.strip(u'\n')
state.append(factor)
print ' '.join(state)


 


在IDLE中运行上述代码:执行结果为:




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: