Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

what is the correct python code to get twitter hashtags?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...