but it returns this error when I run it in python
JavascriptException: Message: javascript error: Cannot read properties of null (reading 'shadowRoot')
(Session info: chrome=109.0.5414.87)
CodePudding user response:
The issue is that the url does not actually point to a pdf file. It's a webpage with an embedded pdf viewer.
By running this I was able to get the actual url to the pdf file:
pdf_url = driver.find_element_by_tag_name('iframe').get_attribute("src")
and then I can just download it with this
import urllib.request
urllib.request.urlretrieve(pdf_url, "test.pdf")