is there a way to save this PDF programmatically?

163 Views Asked by At

Using Delphi 10.1, I have a PDF loaded in a TWebBrowser component. Is there a way to save the PDF programatically, which is displayed in my PDF plugin?

The URL of the PDF (embedded in the site) is: MSDS-File for Productnr G7126 from Sigma-Aldrich

1

There are 1 best solutions below

4
Cyprien On

i don't think that it is possible by web-scraping (as you seem to want), i created this code that is suppose to find all iframes and download it but the urls look really wierd (and it generates an error because of it)

import requests
from bs4 import BeautifulSoup
import urllib

url = "https://www.sigmaaldrich.com/MSDS/MSDS/DisplayMSDSPage.do?country=FR&language=de&productNumber=G7126&brand=SIGMA&PageToGoToURL=https%3A%2F%2Fwww.sigmaaldrich.com%2Fcatalog%2Fsearch%3Fterm%3DG7126%26interface%3DAll_DE%26N%3D0%26mode%3Dmatch%2520partialmax%26lang%3Dde%26region%3DAT%26focus%3Dproduct";
r = requests.get(url)

if r.status_code == 200:
    s = BeautifulSoup(r.text, "html.parser")
    for e in s.find_all('iframe'):
        urllib.request.urlretrieve(e['src'], 'file.pdf')