这是我第一次编写python脚本。我正试图从tiktok网站上提取一个追随者数量,并将其用作字符串。我通过进入chrome中的Inspect窗口,单击跟随者计数,然后右键单击“17M”(在本例中)来保存选择器路径,从而获得了选择器路径。昨天它运行得很好,然后突然停止了,现在无论我怎么尝试,我都无法从这个页面获得“17M”。我正在使用html请求,但一定会尝试美丽的汤或任何其他建议你
from requests_html import HTMLSession
session = HTMLSession()
url = "https://www.tiktok.com/@terrycrews"
r = session.get(url)
sel = '#main > div.jsx-2773227880.main-body.page-with-header.middle.em-follow > div.jsx- 2938571814.share-layout.compact.middle > div > header > h2.count-infos > div:nth-child(2) > strong'
followers = r.html.find(sel, first=True).text
print(followers)
我当前得到的错误是
AttributeError: 'NoneType' object has no attribute 'text'
当我运行此代码时。我希望得到17M
我希望你能提供任何帮助。谢谢大家!
尝试指定
User-Agent
HTTP头:印刷品:
相关问题 更多 >
编程相关推荐