retrieve image from password protected https website

hi everybody,
i'm trying to download an image from a password protected website.
i used wget like this command
wget --no-check-certificate --user=admin
--password=pswd "https://domain.website.com/images/pic1.jpg"
but instead of getting the actual image download i only get the text image of the html code of the download page.
Can someone please help or guide me to the right direction?
gegerismeAsked:
Who is Participating?
 
mccarlConnect With a Mentor IT Business Systems Analyst / Software DeveloperCommented:
You really need to understand the exact nature of how the website is password protected.

If you are using a normal browser to retrieve the image, does the browser pop up a standard dialog to ask for username and password? (In this case the website is probably using 'Basic Authentication' but wget should probably have worked)

Otherwise, if the actual website accepts your username/password, ie. via input form field on the actual web page, then the website is handling authentication itself which means the way you are using wget will not work. The way this works, is that the website receives your username/password and checks it internally and if ok, sends back to you a cookie. You don't see this but the browser saves this cookie, and on each subsequent page request the browser automatically sends this cookie so that the website knows that it is still you. The problem with this is that there is no one standard way the websites use to implement this, and the fact that it is a multi step process.

Check out this link for an example of how to do this multi step process. (The problem that this page is trying to solve should be unrelated to what you are doing, so just check out the wget commands in the question). Note, that you will need to work out the correct "--post-data" string, but viewing your websites login form and working out the names of the form fields for username and password.

So, it may be able to be done, but it is reasonably complicated.

Let us know how you go
0
 
gegerismeAuthor Commented:
thanks for the response mccarl.
i tried the 2 steps process described in the link( wget --quiet --O --no-check-certificate --user=admin --password=admin 'url' then wget --no-check-certificate --save-cookies cookies.txt --post-data --cookies=on --keep-session-cookies --post-data='xx' but it didn't work...
any suggestions? is there something i'm doing wrong?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.