2024-09-18 22:15:53 发布
网友
嘿,我正在尝试用python中的bs4构建一个twitterweb scraper。 它的工作非常好,但我刚刚发现,我还需要刮我刮推的id
python
bs4
在我提交的html图片中,我可以用以下代码将容器“div”{“class”:“tweet”}作为目标:
我似乎无法获取检索“数据项id”的代码。有人知道如何得到它吗? 多谢了
选择using soup.find后,可以将属性作为变量进行访问
soup.find('div',{'class':'tweet'})['data-tweet-id']
这将选择具有类tweet和data tweet id属性的第一个div
选择using soup.find后,可以将属性作为变量进行访问
这将选择具有类tweet和data tweet id属性的第一个div
相关问题 更多 >
编程相关推荐