【问题标题】:How to extract all images in a location using Instagram API?如何使用 Instagram API 提取某个位置的所有图像?
【发布时间】:2016-01-09 10:07:43
【问题描述】:

我想从Instagram API 获取某个位置内的所有图像。

这是我在python中的代码:

from instagram.client import InstagramAPI

client_id = ********
client_secret = ******* 
access_token = *******
client_ip = *******

q = None
count = 100
lat = 51.51608899635712
lng = 0.09891956707558282
min_timestamp, max_timestamp = None, None
distance = 1000

api = InstagramAPI(client_id=client_id, client_secret=client_secret, client_ips=client_ip, access_token=access_token)

media_all_ids = []
media_ids, next = api.media_search(q, count, lat, lng, min_timestamp, max_timestamp, distance)

for media_id in media_ids:
    media_all_ids.append(media_id.id)

主要问题是它给了我这个错误:

media_ids,next = api.media_search(q, count, lat, lng, min_timestamp, max_timestamp, distance)
ValueError: too many values to unpack

我想打印出他们的身份证以及他们的图片链接和拍摄照片的时间。
我想知道是否有人知道如何解决这个问题?

【问题讨论】:

    标签: python api instagram instagram-api


    【解决方案1】:

    media_search方法的正确使用是:

    media_list = api.media_search(q, count, lat, lng, min_timestamp, max_timestamp, distance)
    

    该方法返回Media 对象的列表。
    它不返回媒体对象 ID 列表,您可能会感到困惑,因为打印媒体对象只会打印其 ID,请参见代码 here

    查看Sample App 以获取有关如何使用此客户端的更多示例。

    【讨论】:

      【解决方案2】:
      https://www.instagram.com/explore/locations/US/united-states/?__a=1&page=1
      

      这个页面返回第一页instagram中的所有位置,循环1到12得到美国所有城市(这个是不用API的)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-05
        相关资源
        最近更新 更多