user19113361
user19113361

Reputation: 13

How to search for multiple keywords using snscrape?

is there a way to search multi-words with snscrape? i tried put OR but didnt works

# Creating list to append tweet data to
keywords = "'Slots',' Gambling'"
maxTweets = 200
tweets_list2 = []

# Using TwitterSearchScraper to scrape data and append tweets to list
for i,tweet in enumerate(sntwitter.TwitterSearchScraper(keywords).get_items()):
    if i>maxTweets:
        break
    tweets_list2.append([tweet.date,tweet.id,tweet.content,tweet.user.username,tweet.likeCount,tweet.user.displayname,tweet.lang])
    
# Creating a dataframe from the tweets list above
tweets_df3 = pd.DataFrame(tweets_list2, columns=['Datetime', 'Tweet Id', 'Text', 'Username', 'Like Count', 'Display Name', 'Language'])

Upvotes: 0

Views: 2975

Answers (1)

Artem Tishakov
Artem Tishakov

Reputation: 11

Seems like you can just add as many search terms as you'd like, according to the thread here.

Though, having read that sntwitter uses the Twitter advanced search functionality, you can try to use that to your advantage, and use the same pattern in your search query.

So in your case, it would be (slots OR gambling) as a string as your keywords, and not the list.

Upvotes: 1

Related Questions