【发布时间】:2015-08-15 15:38:20
【问题描述】:
我想要正确的代码
try:
res = self.browser.open('https://login.facebook.com/login.php?login_attempt=1',form_data)
response = res.read()
self.fbid = re.search('https://www.facebook.com/(.*)\?sk=info',response)
self.fbid = re.search('https://www.facebook.com/(.*)',self.fbid.group(1))
self.fbid = re.search('https://www.facebook.com/(.*)',self.fbid.group(1))
except urllib2.HTTPError,e :
print "****exception****inside login error code: %s" % (e.code)
res.close()
except urllib2.HTTPError,e :
print "****exception****inside login error code: %s" % (e.code)
#print " server Response Code: %s " % (res.code)
我收到了这个错误
File "facebotv2.py", line 122, in login
self.fbid = re.search('https://www.facebook.com/(.*)',self.fbid.group(1))
AttributeError: 'NoneType' object has no attribute 'group'
完整代码在这里:https://github.com/pun1sh3r/facebot/blob/master/facebotv2.py
【问题讨论】:
-
也许你应该检查你的每一个正则表达式是否真的返回一些东西,然后再把它塞进下一个正则表达式。似乎其中一个正在返回
None
标签: python regex django attributes regex-group