【发布时间】:2019-05-01 09:32:54
【问题描述】:
我正在尝试下载具有以下 href 的 pdf 文件(我更改了一些值,因为 pdf 包含个人信息)
https://clients.direct-energie.com/grandcompte/factures/consulter-votre-facture/?tx_defacturation%5BdoId%5D=857AD9348B0007984D4B128F1E8BE&cHash=7b3a9f6d109dde87bd1d95b80ca1d
当我在浏览器中通过此 href 时,会直接下载 pdf 文件,但是当我尝试在我的 python 代码中使用 request 时,它只下载源代码
https://clients.direct-energie.com/grandcompte/factures/consulter-votre-facture/
这是我的代码,我使用 selenium 在网站中查找 href
fact = driver.find_element_by_xpath(url)
href = fact.get_attribute('href')
print(href) // href is correct here
reply = get(href, Stream=True)
print(reply) // I got the source code
这是 selenium 找到的 html
<a href="grandcompte/factures/consulter-votre-factue/?tx_defacturation%5BdoId%5D=857AD9348B0007984D4B128F1E8BE&cHash=7b3a9f6d109dde87bd1d95b80ca1d"></a>
我希望你有足够的信息来帮助你,谢谢
【问题讨论】:
-
您能否重新表述一下您到底在寻找什么?