I'm scraping instagram page (https://instagram.com/celmirashop) and get script (HTML and some javascript). the result like this
<script>some script</script>
<script>some script</script>
<script>some script</script>
<script>window._sharedData = {"config":{"csrf_token":"sSqrj6c8tfN1HwOIlwmpqONT2bAPhtNu","viewer":null etc....</script>
I have creating script like this
import urllib.request
import json
import re
from bs4 import BeautifulSoup
web = urllib.request.urlopen("https://instagram.com/celmirashop")
soup = BeautifulSoup(web.read(), 'lxml')
pattern = re.compile(r"window._sharedData = .")
script = soup.find("script",text=pattern)
print(script)
and giving me a result a specific javascript that I want to. like this
<script>window._sharedData = {"config":{"csrf_token":"sSqrj6c8tfN1HwOIlwmpqONT2bAPhtNu","viewer":null etc....</script>
How can I get the value of window._sharedData ? and loop it. because I want save in mysql