+ 2

[** CODE CHALLENGE **] How to save an url that is accessible only after using credentials.

Can i write a program that can save contents of a url as pdf file. The contents of the url are accessible only after entering the credentials (username/password). The program should have attributes to define username & password, login & access the contents of the url, finally save it as a pdf.

26th Aug 2017, 10:25 PM
Das
Das - avatar
9 Answers
+ 8
my Python is good for nothing, but of you share a link to the web page I might be able to give you some directions 😃
27th Aug 2017, 8:55 AM
Nikolay Nachev
Nikolay Nachev - avatar
+ 6
@Amras A I fully agree with @visph on that. Usually you need to post username and password to a certain endpoint to get authentication, but might be completely different...
27th Aug 2017, 3:04 PM
Nikolay Nachev
Nikolay Nachev - avatar
+ 5
Authentification cannot be treated as 'general' case, unfortunally... (but it's logical, as else that will be less secure ;P) Each website could have its own specificities, even some technics could be used commonly (as 'basic' http authetification) ^^
27th Aug 2017, 10:28 AM
visph
visph - avatar
+ 3
I don't know if this is the kind of thing you have in mind but it may be a starting point http://pdfcrowd.com/web-html-to-pdf-JUMP_LINK__&&__python__&&__JUMP_LINK/
26th Aug 2017, 10:33 PM
David Ashton
David Ashton - avatar
+ 2
I mean u can use beautufil soup to write something to a text document and them idk write something that'll change it to a pdf
26th Aug 2017, 10:40 PM
MR.FAKER
MR.FAKER - avatar
+ 1
I think you can try and use the "requests" package, there is a nice way to use authentication
27th Aug 2017, 5:05 AM
Amaras A
Amaras A - avatar
+ 1
@Nikolay Nachev: the point of this exercise is to be general: given a URL, needing authentification, save the content to a pdf file.
27th Aug 2017, 10:21 AM
Amaras A
Amaras A - avatar
0
@David: thank you for giving direction. Now the problem is to pass credentials. Any help appreciated.
26th Aug 2017, 10:44 PM
Das
Das - avatar
0
@faker: thank you.. Does beautiful soup have an agent to send username/password to the website? Yes, saving the file as PDF should be easy.
26th Aug 2017, 10:50 PM
Das
Das - avatar