2013-12-16 3 views
1

내 django 프로젝트에서 특정 twitter 사용자의 mentions을 모두 검색해야하는 시나리오가 있습니다. 나는 사용자의 신임장을 가지고있다. 나는 충분히 제공하지 못했던 검색 API를 시도했다. 나는 모든 언급을 끌어낼 수 없었고, 또한 트위터에 의해 설정된 한계가 내가 추구하는 것을 방해하고 있었다.@user twitter API에 대한 모든 언급 얻기

그래서 now I seek advice whether this can be achieved by the Streaming api or not? 검색된 트윗 정보를 mongodb 데이터베이스에 저장해야 필터 및 사용자 정의 검색을 실행할 수 있습니다. 나는 이것을 위해 twython 패키지를 사용하고있다.

답변

0

인증 된 사용자로부터 검색하려고하는지 확신 할 수 없지만, 이것이 맞습니까? 그것이 최선의 방법인지 아닌지 확실하지 않습니다.

m = twitter.get_mentions_timeline(count=200) 
    calls = 1 
    id = m[-1]['id'] 
    next_id = -1 

    # will continue calling mentions timeline until you hit rate limit 
    # or there are no more mentions of authenticated user 
    while id != next_id and calls < 16: 
     temp = twitter.get_mentions_timeline(count=200,max_id=id) 
     calls += 1 
     next_id = temp[-1]['id'] 
     if id != next_id: 
      m += temp 
      next_id = -1 
      id = temp[-1]['id'] 

m은 인증 된 사용자의 검색된 모든 항목의 배열입니다.

관련 문제