Answer the question
In order to leave comments, you need to log in
How to download photos from instagram by hashes?
The question is, to make a normal download through the apishka from instagram is not a problem.
But how to implement this approach - the user uploads a photo with a hashtag to Instagram, and it is uploaded to the server. I understand that you need to set some kind of background task so that after a certain interval it checks for a new photo.
Please suggest or express your thoughts on how to implement this.
A little more detail if possible)
Answer the question
In order to leave comments, you need to log in
It is important to know here whether this is a new, unique tag, whether a full history of photos for this tag is needed, etc.
1. Get a list of recent photos with the desired tag and save them to the database:
2. From the answer we take pagination.next_min_id
and save it for the next request.
2.a If you need a history for this tag, then make the next request using the link from pagination.next_url
or generate it yourself with an indication next_min_id
from the pagination
object, and so on until this parameter ( next_url
) is in the response or just until you get bored.
3. We request new photos indicating the parameter next_min_id
and save them to the database:
4. GOTO 3.
There is a problem that I have not been able to solve yet. This algorithm works until you have a lot of photos with this tag and they all fit into one response to an API request. (parameter count
can be from 1 to 32). As soon as the number of new photos exceeds the number of new photos during the time you make a request to the API and show / save photos to the database count
, you will need to download new pages next_url
and with each iteration there will be more and more such pages (try the tag love
for example).
The behavior of the tag method with a parameter next_min_id
is not at all clear to me, because by specifying this parameter, count=1
I expect to see exactly one photo published on Instagram immediately after the one with thisnext_min_id
and was, but in fact the answer will contain the most recent photo of all that appeared in the period after next_min_id
and a link to the next portion of photos from this group in next_url
. How to solve this - I don't know, here is my question on SO .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question