ckoepp / TwitterSearch

A Python library to easily iterate tweets found by the Twitter Search API
MIT License
387 stars 112 forks source link

Find all tweets near me? #31

Closed WaltersGareth closed 8 years ago

WaltersGareth commented 8 years ago

Hi, I am new to this. I have been able to get a script going using TwitterSearch by passing in a keyword or two, but can I mimic the near me function of the actual twitter search (more) options?

I tried different variations like this: tso.set_keywords([], or_operator = True) # let's define all words we would like to have a look for tso.set_geocode(138.599,-34.93,10,imperial_metric=True)

Any help would be appreciated.

ckoepp commented 8 years ago

The logical OR is only available to keywords. There is no way to search for "foobar OR any tweets near me". This is due to the way the Twitter API works. Those logical operators are only working when it comes to keywords.

Though, you can compose a search like "get me all tweets containing foobar OR barfoo within the range 138.599, -34.93". Just use the set_keyword method as you did before and set the geocode:

tso.set_keywords(["foobar", "barfoo"], or_operator=True)
tso.set_geocode(138.599,-34.93,10,imperial_metric=True)