'how to automate saving web pages as PDF or HTML files using python

I have about 300 web URLS. I'll save them either as PDF or as HTML pages. In order to have access to these web pages I must be logged in.

I've tried chrome --headless but it saves a blank page!

chrome --headless --print-to-pdf="C:\\1.pdf" https://myurl.com

I wanted to try selenium in python but it has always opened a new Session where I wasn't logged in. I've used this code

Could you please suggest me a solution?

Best Regards



Solution 1:[1]

first I opened a session with selenium and I logged in manually. Then I used the same session again (so reconnected) So I could access the pages in a Loop and save them

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shahram Shinshaawh