且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Instagram的API的Python用户后跟

更新时间:2023-01-02 22:27:21

您需要使用分页。 API响应应该包括一个名为 next_url 价值,称那你会得到50个用户。有没有办法不分页,让他们的一次。

You need to use pagination. The API response should include a value called next_url, call that an you'll get 50 more users. There's no way to get them all at once without paginating.

请参阅 http://instagram.com/developer/endpoints/

在你的情况,你似乎是使用Python API库,所以加 as_generator = TRUE 当你调用 user_followed_by 。这应该返回一个发电机对象,您可以遍历。

In your case, you appear to be using the Python API Library, so add as_generator=True when you call user_followed_by. That should return a generator object that you can iterate over.

def example():
    generator = api.user-followed_by(as_generator=True, max_pages=None)
    for page in generator:
        print page #page will have the next 50 users, etc