如何使用SNSCrape搜索多个关键字?
有没有办法用SNSCrape搜索多字?我尝试过或没有起作用
# 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'])
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'])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎您可以根据线程添加尽可能多的搜索术语,根据线程在这里。
不过,阅读了 sntwitter使用Twitter高级搜索功能,您可以尝试使用为了您的优势,并在搜索查询中使用相同的模式。
因此,就您而言,它将是(插槽或赌博)作为字符串作为关键字,而不是列表。
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.