python - “NoneType”对象不可迭代:怎么办?
问题描述
我尝试构建一个网络爬虫,但不幸的是我不知道如何处理以下错误消息?有没有人想到解决方案?“调用”包含我要抓取的页面的源代码,它不是“无”,但当print(test)
我收到“无”。实际上,我不确定是否
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
解决方案
推荐阅读
- python - 使用 pyodbc UPDATE 命令更新 sql 表时如何解决 SQL 绑定错误?
- c# - TcpListener.AcceptTcpClientAsync 方法不监听客户端请求
- javascript - Azure Timeseries 见解 API 所有 API 请求的内部服务器错误
- php - 从mysql获取记录,不包括值
- python - 如何从另一列的范围计算一列的平均值
- c# - 将 JSON 从多个对象反序列化为对象列表
- php - PHP readfile 总是返回“网络错误”
- spring-data-jpa - 如何在jpa中加入ON?( Spring Data Jpa 1.4 )
- javascript - 将具有相同键的嵌套对象合并到 JavaScript 中的单个对象中
- javascript - 使用 Google 表格将 HTML 编码为 HTML 特殊字符