Get Info From Script Tag (webscrape)
#Python Code from bs4 import BeautifulSoup import urllib3 url ='https://www. SomeData .com' req = urllib3.PoolManager() res = req.request('GET', url) soup = BeautifulSoup(res.data
Solution 1:
Please check if this helps.
script = soup.find('script', text=re.compile('AAA\.trackData\.taxonomy'))
json_text = re.search(r'^\s*AAA\.trackData\.taxonomy\s*=\s*({.*?})\s*;\s*$',
script.string, flags=re.DOTALL | re.MULTILINE).group(1)
data = json.loads(json_text)
Post a Comment for "Get Info From Script Tag (webscrape)"