Python要求下载pdf新窗口

时间:2019-11-19 20:02:54

标签: python pdf download python-requests screen-scraping

我对此很陌生。 我正在尝试从网站下载pdf。该网站要求进行身份验证才能访问。登录后,我将自己重定向到网站的另一部分,并搜索要下载的pdf。为了下载pdf文件,我必须单击网站上的一个小按钮,然后提示打开一个新窗口并打开该窗口,然后开始下载pdf文件。到目前为止,这就是我所拥有的。我已经排除了由于敏感信息而宣布的一些词典。

import requests

with requests.Session() as s:
    'This is the url where I have to login
    url = 'https://appa.nbcn.ca/welcome/login.do'
    r = s.get(url)
    r = s.post(url, data=login_data, headers=headers)

    'This is the url where i search for the pdf 
    url = 'https://appa.nbcn.ca/javagon/search/process.do'
    r = s.get(url)
    r = s.post(url, data=search, headers=headers2)

    'Now that I've searched for the pdf, I need to know how to code something that 
     presses that download button and prompt the new window to start downlaoding 
     the pdf

with open('C:/Users/clazar/Desktop/JRFQ/yurr.pdf', 'wb') as f:
    f.write(r.content)

0 个答案:

没有答案
相关问题