受密码保护的PDFKIT仅打印登录页面

时间:2019-04-06 17:54:01

标签: python-3.x request pdfkit

将PDFKIT与受密码保护的站点一起使用。使用请求时将用户名和密码作为数据传递。Post(url,data)不能按预期工作

loginURL = 'https://registration.vtbigevent.org/account/login'
url = 'https://registration.vtbigevent.org/committee/jobs/jif/id/'
config = pdfkit.configuration(wkhtmltopdf="C:/Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe")
loginInfo = {
    'pid': 'XXXXX',
    'id': 'XXXXXX'
}

# Use 'with' to ensure the session context is closed after use.
with requests.Session() as start:
    login = start.post(loginURL, data=loginInfo)

    for ids in idsNotCancelled:
        pdf = str(ids) + '.pdf'
        new_url = start.get((url + str(ids)))
        pdfkit.from_url(new_url.url, pdf, configuration=config)

它仍会打印登录屏幕的pdf而不是预期的受保护页面。

0 个答案:

没有答案