1
stream.filter(locations=[-122.75,36.8,-121.75,37.8,-74,40,-73,41],track=["twitpic"])
This Works。但是,這不是「與」。這是「或」。該行獲取位置OR關鍵字。 如何製作「AND」?如何使用Twitter流媒體API?
這裏的代碼庫我使用:
def filter(self, follow=None, track=None, async=False, locations=None):
self.parameters = {}
self.headers['Content-type'] = "application/x-www-form-urlencoded"
if self.running:
raise TweepError('Stream object already connected!')
self.url = '/%i/statuses/filter.json?delimited=length' % STREAM_VERSION
if follow:
self.parameters['follow'] = ','.join(map(str, follow))
if track:
self.parameters['track'] = ','.join(map(str, track))
if locations and len(locations) > 0:
assert len(locations) % 4 == 0
self.parameters['locations'] = ','.join(['%.2f' % l for l in locations])
self.body = urllib.urlencode(self.parameters)
self.parameters['delimited'] = 'length'
self._start(async)
https://github.com/joshthecoder/tweepy/blob/master/tweepy/streaming.py