我正在使用tweepy库编写代码,以收集包含特定用户ID的所有推文。对于此示例,假设我要查找与Austrian Airlines
相关的所有推文要实现这样的目标(假设我可以使用twitter API),我将要做的事情是这样的:
import pandas as pd
import numpy as np
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
from tweepy import API
from tweepy import Cursor
auth = OAuthHandler(twitter_credentials['CONSUMER_KEY'],twitter_credentials['CONSUMER_SECRET'])
auth.set_access_token(twitter_credentials['accESS_TOKEN'],twitter_credentials['accESS_TOKEN_SECRET'])
api = API(auth,wait_on_rate_limit=True,wait_on_rate_limit_notify=True)
# Search word/hashtag value
HashValue = '_austrian'
# search start date value. the search will start from this date to the current date.
StartDate = "2019-11-11" # yyyy-mm-dd
for tweet in Cursor(api.search,q=HashValue,count=1,lang="en",since=StartDate,tweet_mode='extended').items():
print (tweet.created_at,tweet.full_text)
但是,这种方法似乎并没有返回我期望的结果。我刚得到一系列推文,其中提到了奥地利一词。
我该怎么做才能只获得包含_austrian的推文?