Home > Mobile >  How to pass an url generated through selenium (logged in to a website) to the PyQt5 (to create a pdf
How to pass an url generated through selenium (logged in to a website) to the PyQt5 (to create a pdf

Time:10-21

Basically, I want to log in to the website and generate a pdf of that particular webpage. For login purposes, I am using selenium webdriver (chrome), and to extract pdf I have tried pdfkit, wkhtmltopdf, weasyprint but they are not working as expected (not able to print/create pdf properly).

PyQt5 is using its own HTTP request (which results in creating pdf of login form which is not required) and not able to reach the expected URL (logged in with selenium webdriver).

selenium webdriver:-

tmp = driver.get(r"https://URL")

PyQt5 piece of code:

loader = QtWebEngineWidgets.QWebEngineView()
loader.load(QUrl(tmp))

loader.page().printToPdf("test_profile.pdf", pageLayout=pdfLayout)

CodePudding user response:

Try using pyppeteer (Unofficial Python port of puppeteer), its more efficient for saving as PDFs.

  • Related