Reputation: 51
I want to scrape a tweet from Twitter with a keyword in the form of the name of an internet service provider, but I want to exclude the customer service account from that internet service provider. What should I add in my code?
consumer_key = 'xxxx'
consumer_secret = 'xxxxx'
access_token = 'xxxx'
access_token_secret = 'xxxxx'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth,wait_on_rate_limit=True)
csvpefile = open ('test1.csv', 'a')
csvWriter = csv.writer(csvpefile)
for tweet in tweepy.Cursor(api.search,
q=["telkomsel"],
count=6000,
lang="id",
since="2020-09-23",
tweet_mode = 'extended',
trucated='false').items(6000):
tweettext = str(tweet.full_text.lower().encode('ascii',errors='ignore'))
if tweettext.startswith("rt @") == False and hasattr(tweet, 'retweeted_status') == False:
csvWriter.writerow([tweet.user.id, tweet.created_at, tweet.id, tweet.full_text.encode('utf-8')])
print(tweet.user.id, tweet.created_at, tweet.id, tweet.full_text)
Upvotes: 0
Views: 55
Reputation:
You could try q=["telkomsel -from:telkomsel"]
This should find references to that account but exclude Tweets sent from that account.
Upvotes: 0