You need soup to get the necessary script tag from the page code. The content of this tag is a json object.
from bs4 import BeautifulSoup import json import re src = '<script type="text/javascript">window._sharedData = {"activity_counts":null,"config":"","dimensions":{"height":1350,"width":1080},"display_url":"https://scontent-arn2-1.cdninstagram.com/vp/d60f1dbd5f2a609e6a653569a8a13a11/5B807715/t51.2885-15/e35/31297890_370834860094260_8326112321717927936_n.jpg"}</script>' soup = BeautifulSoup(src, 'lxml') script = soup.find('script') #здесь нужно указать доп.условия поиска именно вашего тега json_text = re.findall('^s*window\._sharedData\s*=\s*({.*?})\s*\s*$', script.string, flags=re.DOTALL | re.MULTILINE)[0] js = json.loads(json_text) print(js['display_url'])