python实现人人网登录示例分享

2018-09-26 20:03

阅读:490

  复制代码 代码如下:
import re
import urllib2
import cookielib

  def renren():
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
email =
pwd =

#登录..
print login......
url =
postdata = email=+email+&password=+pwd+&origURL=http%3A%2F%2F
req = urllib2.Request(url,postdata)
res = opener.open(req).read()
print succeed!

#得到当前状态
s = r(?s)id=currentStatus>.*?<a ui-async=async title=([^]*)
match = re.search(s, res, re.DOTALL)
if match:
result = match.groups(1)
print current status: , result[0]

  renren()


评论


亲,登录后才可以留言!