用Python爬虫出现了题目所述的问题,求大神解答以下,救救小白吧,哭了
代码如下:
Result=Soup.find('div',class_='tip-text ugc-ellipsis fade-text').text.strip()
错误提示:
AttributeError Traceback (most recent call last)
in
----> 1 Result=Soup.find('div',class_='tip-text ugc-ellipsis fade-text').text.strip()
AttributeError: 'NoneType' object has no attribute 'text'
我刚刚也碰到这个问题了,我的问题是上一层的进行beautifulSoup的定位标签位置过大,造成在进行循环时,找不到对应的的标签,抛出异常。
你可以打印一下可迭代对象的大小,跟预期是否一致