Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter Tweepy:我怎么能从一个用户那里获得20条以上的推文?_Twitter_Tweepy - Fatal编程技术网

Twitter Tweepy:我怎么能从一个用户那里获得20条以上的推文?

Twitter Tweepy:我怎么能从一个用户那里获得20条以上的推文?,twitter,tweepy,Twitter,Tweepy,根据: 那么,我怎样才能从一个人的时间线上获得20条以上的推文呢?这些文档没有显示该用户需要如何进行身份验证?您可以使用API.user\u时间线([id/user\u id/screen\u name][,since\u id][,max\u id][,count][,page])中的pages参数。对于pagevalue 1,您将从用户时间线中获得一组最新的20条tweet,然后在进一步迭代中,当我们增加page=2的值时,该方法将返回其他20条tweet,这些tweet比从第1页收到的最旧

根据:


那么,我怎样才能从一个人的时间线上获得20条以上的推文呢?这些文档没有显示该用户需要如何进行身份验证?

您可以使用
API.user\u时间线([id/user\u id/screen\u name][,since\u id][,max\u id][,count][,page])中的
pages
参数。对于
page
value 1,您将从用户时间线中获得一组最新的20条tweet,然后在进一步迭代中,当我们增加
page=2的值时,该方法将返回其他20条tweet,这些tweet比从第1页收到的最旧tweet更早,您可以认为:

假设您的帐户中有120条推文(第一条推文是最早的,第120条推文是最新的),那么:

page=1
将返回(100120)

page=2
将返回(80100)

……等等

我希望你现在了解了页面的概念,是时候实现这些东西了

no_of_pages = int(raw_input("Please enter the number of tweets: "))
for i in xrange(no_of_pages):
    API.user_timeline("@anmoluppal366", page = i)

您还可以使用max_id参数

r0 = api.user_timeline("@donaldtrump") # gives 20 latest tweets
idlast = r0[-1].id # the last id of these 20
r1 = api.user_timeline("@donaldtrump", max_id = idlast) # next 20 tweets older or same age as idlast

你知道如何使用Ruby做到这一点吗?@marriedjane875看一看:你为什么这么棒?@anmol_uppal
page
不再是这个方法中的有效参数,请检查。记住,你只能获得最近3200条推文。如果你想获得更多,还需要其他方法。
r0 = api.user_timeline("@donaldtrump") # gives 20 latest tweets
idlast = r0[-1].id # the last id of these 20
r1 = api.user_timeline("@donaldtrump", max_id = idlast) # next 20 tweets older or same age as idlast