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
CodePudding user response:
You can use startswith()
method to sort and to get the data items those contain onlt #
for tag in hashtags:
if tag.startswith('#'):
print(tag.text)
CodePudding user response:
You cal filter the list with a comprehension:
hashtags = ["@flutter_coding_", "#softwareengineer", "#iosdeveloper"]
hashtags = [i for i in hashtags if i[0]=="#"]
print(hashtags )
Output:
['#softwareengineer', '#iosdeveloper']