I am posting my first question on stackoverflow and thanks in advance to anyone to help. the below is what I used to get tweets and the hashtags in tweets which look like 'entities': {'hashtags': [{'text': 'COVID19', 'indices': [107, 115]}]. To get the hashtags, I tried
for tweet in (tweets):
hashtags = []
try:
for hashtag in tweet.entities['hashtags']:
for text,indices in hashtag:
hashtags.append(['text']['indices'])
But got an empty list [] for hashtags. would you please help me find out what's wrong and what is the correct code for this? Thank you
To get Tweets
search_words = ""
date_since = "2018-01-01"
date_until="2021-01-13"
tweets = tw.Cursor(api.search,
q=search_words,
lang="en",
since=date_since,
until=date_until
).items()
question from:
https://stackoverflow.com/questions/65838066/what-is-the-correct-python-code-to-get-twitter-hashtags 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…