arias_JC
arias_JC

Reputation: 559

How to get cookies from mechanize to use in pdfkit

Does anyone know how to get a cookie that I have logged into using mechanize browser, so that I can use those urls in pdfkit? I have looked around a bit, but can't manage to see how to get a cookie in the right format and pass it to pdfkit.from_url.

Upvotes: 0

Views: 190

Answers (1)

georgexsh
georgexsh

Reputation: 16634

wkhtmltopdf support set cookie with --cookie option, extract cookies from mechanize browser, pass to wkhtmltopdf with argument options of pdfkit.from_url:

cj = br.cookiejar # assume `br` is a `browser` intance
ops = {'cookie': [(c.name, urllib.quote(c.value)) for c in cj]}
pdfkit.from_url('url', options=ops)

Upvotes: 1

Related Questions