2010-11-07 112 views
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

回答

2

http://dev.twitter.com/pages/streaming_api_methods#locations

邊框進行邏輯OR值。甲 位置參數可被組合 與軌道參數,但請注意, 所有術語邏輯ORD,所以 查詢字符串 軌道=嘰嘰喳喳&位置= -122.75,36.8,-121.75,37.8 將匹配包含任何鳴叫 來自舊金山地區的術語Twitter(即使是非地理推文)或 。

...

多個包圍盒可以通過級聯 緯度/經度對,例如指定 : 位置= -122.75,36.8,-121.75,37.8,-74,40 ,-73,41將跟蹤來自舊金山 和紐約市的推文。

欲瞭解更多信息,請閱讀完整的文檔。