[英]How to extract all images in a location using Instagram API?
I want to get all images within a location from the Instagram API
.我想从
Instagram API
获取某个位置内的所有图像。
Here is my code in python
:这是我在
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)
The main problem is it gives me this error:主要问题是它给了我这个错误:
media_ids,next = api.media_search(q, count, lat, lng, min_timestamp, max_timestamp, distance)
ValueError: too many values to unpack
I want to print out their IDs alongside their image link and the time the photo was captured.我想打印出他们的 ID 以及他们的图像链接和拍摄照片的时间。
I was wondering if someone knows how to solve this issue?我想知道是否有人知道如何解决这个问题?
https://www.instagram.com/explore/locations/US/united-states/?__a=1&page=1
This page returns all the locations in the instagram in the first page, loop through 1 to 12 to get all the US cities ( This is without use of API )这个页面在第一页返回instagram中的所有位置,循环1到12得到所有美国城市(这是不使用API的)
The correct use of the media_search
method is: media_search
方法的正确使用是:
media_list = api.media_search(q, count, lat, lng, min_timestamp, max_timestamp, distance)
The method returns a list of Media
objects.该方法返回
Media
对象列表。
It does not return a list of media object IDs, you might got confused because printing a Media object will print only its ID, see the code here
.它不返回媒体对象 ID 列表,您可能会感到困惑,因为打印媒体对象只会打印其 ID,请参阅
here
的代码。
Check out Sample App
for more examples on how to use this client.查看
Sample App
以获取有关如何使用此客户端的更多示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.