retrieve image from password protected https website

Posted on 2012-09-17
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 ""
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 35

    Accepted Solution

    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

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now