[英]AttributeError: 'NoneType' object has no attribute 'group' error
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)
i got this 我懂了
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'
self.fbid
is None
after your first regular expression search. 第一次正则表达式搜索后,
self.fbid
为None
。 This probably means that you didn't find a match. 这可能意味着您找不到匹配项。 If you want to prevent the error, you can conditionally only continue searching the result of the initial search with
if self.fbid != None
如果你想防止错误,你可以有条件地只用
if self.fbid != None
继续搜索初始搜索的结果if self.fbid != None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.