[Last Call] Learn how to a build a cloud-first strategyRegister Now


retrieve image from password protected https website

Posted on 2012-09-17
Medium Priority
Last Modified: 2013-11-19
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?
Question by:gegerisme
LVL 36

Accepted Solution

mccarl earned 900 total points
ID: 38408086
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

Author Comment

ID: 38466485
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?

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Simple Linear Regression
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question