JustAnotherArchivist / snscrape

A social networking service scraper in Python
GNU General Public License v3.0
4.33k stars 699 forks source link

Twitter search for keyword returns username, display name, and URL matches #160

Closed shizia closed 3 years ago

shizia commented 3 years ago

Hello! I encounter a problem. I use for i, tweet in enumerate(snscrape.modules.twitter.TwitterSearchScraper("COVID19 since:2020-02-01 until:2020-02-02").get_items()):, but the result is strange, the tweets didn't include COVID19, instead, all usernames include COVID19. But I want to scrape tweets which include COVID19 , not username. How to slove this problem?

JustAnotherArchivist commented 3 years ago

I'm afraid that's just how Twitter's search works. Specifically, a search term matches on the username, the display name, the tweet text, and URLs, as far as I know. I'm not aware of a way to filter those other matches out directly; you'd have to do something like this instead for your case:

if 'covid19' not in tweet.content.lower():
    continue
shizia commented 3 years ago

I'm afraid that's just how Twitter's search works. Specifically, a search term matches on the username, the display name, the tweet text, and URLs, as far as I know. I'm not aware of a way to filter those other matches out directly; you'd have to do something like this instead for your case:

if 'covid19' not in tweet.content.lower():
  continue

I see, thank you very much!!