仅当以'#'开始时,如何获取数据。 Python
您好,我想从字幕中获取主题标签列表。 只有仅数据以“#”开头,
hashtags = driver.find_elements(By.CSS_SELECTOR, "li > div > div > div._a9zr > div._a9zs > span > a")
for tag in hashtags:
print(tag.text)
它仍然与 @ data混合在一起,才会刮擦数据
@flutter_coding_
#softwareengineer
#iosdeveloper
#webdeveloper
#flutterdeveloper
#frontenddeveloper
#appdeveloper
#programming
#softwareengineer
#coding
#code
#100daysofcode
#javascript
#reactjs
#developer
#developerlife
#programminghumor
#coderlife
#python
#php
#desksetup
#appdevelopment
#uidesign
#frontend
#backenddeveloper
#codinggirl
#flutter
Hello im trying to get hashtags list from caption..
only will scraping data if only the data start with '#'
hashtags = driver.find_elements(By.CSS_SELECTOR, "li > div > div > div._a9zr > div._a9zs > span > a")
for tag in hashtags:
print(tag.text)
it still mixed with @ data
@flutter_coding_
#softwareengineer
#iosdeveloper
#webdeveloper
#flutterdeveloper
#frontenddeveloper
#appdeveloper
#programming
#softwareengineer
#coding
#code
#100daysofcode
#javascript
#reactjs
#developer
#developerlife
#programminghumor
#coderlife
#python
#php
#desksetup
#appdevelopment
#uidesign
#frontend
#backenddeveloper
#codinggirl
#flutter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过理解来过滤列表:
输出:
You cal filter the list with a comprehension:
Output:
您可以使用
startswith()
方法进行排序并获取仅包含#
的数据项尝试:
首先,您必须调用
.text
方法,然后startswith(
)`与条件You can use
startswith()
method to sort and to get the data items those contain only#
Try:
At first,you have to invoke
.text
method thenstartswith(
)` method with if condition