Я пытаюсь загрузить и сохранить все файлы из: https://www.bankia.es/es/pymes-y-autonomos/buscador-documentacion-precontractual
Доступно более 1200 файлов, поэтому я подумал об использовании какого-то цикла.Я понял, что все они содержат один и тот же частичный href: href = "/ estaticos / documentsmentosPRIIPS / xxxx.PDF"
Вот что я попробовал:
soup = BeautifulSoup(html_doc, 'html.parser')
savepath = 'my_path' # set the desired path here for the files
options = webdriver.ChromeOptions()
options.add_experimental_option('prefs', {
"download.default_directory": "my_path",
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"plugins.always_open_pdf_externally": True
}
)
url_bankia= "https://www.bankia.es/es/pymes-y-autonomos/buscador-documentacion-precontractual"
bankia_request = requests.get(url_bankia)
bankia_web = BeautifulSoup(bankia_request.text, "html.parser")
bankia_web.find_all("a", href=re.compile(r"^/estaticos/documentosPRIIPS/"))