python自动登录人人网的脚本 出啥问题了呢?求解ing 帮忙吧大大们
#encoding=utf-8
import sys,re,urllib2,urllib,cookielib
class renren(object):
def __init__ (self):
self.name=self.pwd=self.content=self.domain=self.origURL=''
self.operate=''
self.cj=cookielib.LWPCookieJar()
self.cj.revert('renren.coockie')
self.opener=urllib2.build_opener(urllib2.HTTPCookieProessor(self.cj))
urllib2.install_opener(self.opener)
def setinfo(self,username,password,domain,origURL):
self.name=username
self.pwd=password
self.domain=domain
self.origURL=origURL
def login(self):
params={'domain':self.domain,'origURL':self.origURL,'email':self.name,'password':self.pwd}
print ('login...')
req=urllib2.Request('http"//www.renren.com/PLogin.do',urllib.urlencode(params))
self.operate=self.opener.open(req)
if self.operate.geturl()=='http://www.renren.com/Home.do':
print ('ok!!')
self.cj.save('renren.coockie')
self.__viewnewinfo()
else:
print ('no!!')
ren=renren()
username=
password=
domain='renren.com'
origURL='http://www.renren.com/Home.do'
ren.setinfo(username,password,domain,origURL)
ren.login()
#encoding=utf-8import sys,re,urllib2,urllib,cookielibclass renren(object): def __init__ (self): self.name=self.pwd=self.content=self.domain=self.origURL='' self.operate='' self.cj=cookielib.CookieJar() #self.cj.revert('renren.cookie') self.opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj)) urllib2.install_opener(self.opener) def setinfo(self,username,password,domain,origURL): self.name=username self.pwd=password self.domain=domain self.origURL=origURL def login(self): params={'domain':self.domain,'origURL':self.origURL,'email':self.name,'password':self.pwd} print 'login...' req=urllib2.Request('http://www.renren.com/PLogin.do',urllib.urlencode(params)) self.operate=self.opener.open(req) if self.operate.geturl()=='http://www.renren.com/Home.do': print 'ok!!' #self.cj.save('renren.coockie') #self.__viewnewinfo() else: print 'no!!' ren=renren()username='你的账号'password='你的密码'domain='renren.com'origURL='http://www.renren.com/Home.do'ren.setinfo(username,password,domain,origURL)ren.login()