Answer the question
In order to leave comments, you need to log in
How to parse multiple photos/videos in one Instagram post?
Hello!
My task is to get pictures from any Instagram post.
I managed to make it so that you can get only one picture, in posts where there are several photos / videos, I only get a link to the first picture.
Here is the code:
from bs4 import BeautifulSoup as BS
import requests
URL = 'https://www.instagram.com/p/B89F_agFwrF/'
r = requests.get(URL)
soup = BS(r.content, 'html.parser')
link = soup.find('meta', {'property': 'og:image'}).get('content')
print(link)
Answer the question
In order to leave comments, you need to log in
so they are all sent in json to the post sequentially, take it and parse it, what is the actual problem of collecting them?
You need to parse this json data:
https://www.instagram.com/graphql/query/?query_hash=5789ea2c88978c55ccd762cb99e7b8bf&variables={"shortcode":"B_8MQ67h-mf"}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question