I am trying to access an element in
<script type="text/javascript">ReportPopper("http://asd.asd.asd/ReportOutput/asd-asd-41cc-asd-asd.xls");<script>
using beautifulsoup, unfortunately I'm not sure on how to access the ReportPopper part and assign it to a variable using Python
Sorry if this is already answered. I've tried adding ReportPopper in the find('ReportPopper') and gives me a none element.
import requests
import io
import os
from bs4 import BeautifulSoup
participation = requests.post(url=report_post_url,data=request_post_report_form,headers=report_post_headers,stream=True)
print(participation)
soup = BeautifulSoup(participation.text, 'html.parser')
for n in soup.find_all('script'):
javascript = n['ReportPopper']
print(javascript)
I want to get my end result as:
javascript = "http://asd.asd.asd/ReportOutput/asd-asd-41cc-asd-asd.xls"
as my output:
Traceback (most recent call last):
File "c:\Users\John asd\Documents\GitHub\asd.net\testing.py", line 184, in <module>
javascript = n['ReportPopper']
File "C:\Users\John asd\asd\Local\Programs\Python\Python37\lib\site-packages\bs4\element.py", line 1016, in __getitem__
return self.attrs[key]
KeyError: 'ReportPopper'