【发布时间】:2022-01-07 00:41:38
【问题描述】:
我参加了一个 udemy 课程,讲师教授如何获取用户推文。
当我运行代码时它给了我
AttributeError: 'NoneType' 对象没有属性 'getText'
在 udemy 上没有得到很好的支持,所以如何使这段代码工作。
from bs4 import BeautifulSoup as soupy
import urllib.request
import re
html = urllib.request.urlopen('https://twitter.com/samad_bloch0x1').read()
soup = soupy(html, features="html.parser",)
x = soup.find('p', {'class':'js-tweet-text'}).getText()
filter = re.findall(r'"(.*)"', x)ut
tweet = filter[0]
print(tweet)
这是我的全部代码
【问题讨论】:
标签: python web web-scraping twitter typeerror