|go ahead... be a heretic|
Using LWP (or some other module) to Dowload HTML with Cookie Session IDby Leudwinus (Scribe)
|on Nov 28, 2022 at 02:58 UTC ( #11148411=perlquestion: print w/replies, xml )||Need Help??|
Leudwinus has asked for the wisdom of the Perl Monks concerning the following question:
Hello Fellow Monks,
I am trying to download the HTML of a URL which requires authentication (username and password). Using curl, I am able to successfully do this via:
curl https://example.com --cookie "session=536...035a" -o "HTML_output.txt"
where the session ID is the one I obtained via the browser's developer tools function.
I am trying to replicate this using a more "native" Perl approach and using the LWP module, I have the following code which allows me to get the HTML of a given URL that does not require any authentication:
Is there a way using LWP (or some other module) to also include the session ID from the browser cookie?
Thank you in advance.
As a quick update, I have modified my code to use HTTP::Cookies::Netscape as follows:
Unfortunately, when I run that, the response that comes back tells me that I still need to supply a proper username and password, even though my session is still valid on the browser. I used the Firefox add-on "cookies.txt" to download a cookies.txt file which looks like:
Back to Seekers of Perl Wisdom