首页 > 解决方案 > “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

标签: pythonjupyter-notebookweb-crawlernonetype

解决方案


推荐阅读