【发布时间】:2017-07-12 03:32:10
【问题描述】:
我正在尝试获得 10 条推文。我将计数设置为 5 并应用“在 range(2) 内”。这意味着它应该检索不超过 10 条推文。但是,这里它给了我 15 条推文,其中推文 1 到 5 的推文 ID 出现了两次。
alltweet=[]
def rest_query_ex3():
query = "road"
geo = "42.6525,-73.7572,9mi"
MAX_ID = None
for it in range(2): # should Retrieve up to 10 tweets
tweets = myApi.search(q=query, geocode=geo, count=5, max_id=MAX_ID)
if tweets:
MAX_ID= tweets[-1].id
alltweet.extend(tweets)
for pk in alltweet:
print pk.id
if __name__ == '__main__':
rest_query_ex3()
在这张图片中,一些推文 ID 重复并给了我超过 10 条推文。有人可以在python中使用rest_api帮助我吗 enter image description here
【问题讨论】:
标签: python json python-2.7 python-3.x dataset