如何解决'NoneType' 对象不可迭代:怎么办?
我尝试构建一个网络爬虫,但不幸的是我不知道如何处理以下错误消息?有没有人想到解决方案? “Call”包含我想要抓取的页面的源代码,它不是“none”,但是当我执行 print(test)
时,我收到“none”。其实,我不完全确定
test = call.find('p',class_ = re.compile('p p*'))
是正确的。有什么想法吗?
#Testing if URL contains necessary elements
test_list = []
test = call.find_all('p',class_ = re.compile('p p*'))
for c in test:
x = c.text.strip()
test_list.append(x)
if ('Operator' in test_list) and ('Conference Call Participants' in test_list):
#Basic Company Info Section
#Create cc_id
cc_id = counter
很遗憾,我收到以下错误消息:
TypeError Traceback (most recent call last)
<ipython-input-51-c44d70d4fe49> in <module>
1 #Pull page details
----> 2 pullpagedetails(take1)
<ipython-input-50-afd0a6c99d59> in pullpagedetails(Url_list)
45 test_list = []
46 test = call.find('p',class_ = re.compile('p p*'))
---> 47 for c in test:
48 x = c.text.strip()
49 print(x)
TypeError: 'NoneType' object is not iterable
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。