使用selenium下载pdf

2024-04-30 01:22:40 发布

您现在位置:Python中文网/ 问答频道 /正文

正在尝试使用Selenium下载pdf

我的代码


bills_href = selenium_controller.search_bills(browser)
    for count,i in enumerate(bills_href):
        r = requests.get(i, stream=True,verify=False)
        with open(("python%s.pdf")%(count), "wb") as pdf:
            for chunk in r.iter_content(chunk_size=1024):

                if chunk:
                    pdf.write(chunk)
bills_href = list of links of pdf

但是当我打开我的PDF文件时,它显示它已损坏 甚至打不开