0

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.

arias_JC
  • 549
  • 3
  • 15

1 Answers1

1

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)
georgexsh
  • 15,984
  • 2
  • 37
  • 62