title: Downloading a File with Python Or Wget with authentication
body: <p>So basically I have tried numerous methods to download this file. I have both Python
  and wget implementations. And really at this point could care less which one I can get to work.</p>
  
  <p>Both do the same exact thing... They download the webpage, not the file I'm trying to download. Yet when I post the exact url provided into firefox, it immediately prompts me to download it.</p>
  
  <p>What needs to happen:
  1. connect to website (even though ssl is messed up on it?)
  2. Authenticate myself
  3. click the first link, which redirects to a download file
  4. Download that file</p>
  
  <p>First up my python code:</p>
  
  <pre><code>import httplib2
  import urllib2
  from BeautifulSoup import BeautifulSoup, SoupStrainer
  
  http = httplib2.Http()
  http.add_credentials('username', 'password')
  status, response = http.request('https://traveler.pha.phila.gov:8443/servlet/traveler')
  
  counter = 0
  Androidlink = ''
  Windowslink = ''
  Iphonelink = ''
  
  for link in BeautifulSoup(response, parseOnlyThese=SoupStrainer('a')):
      if link.has_key('href'):         
          if counter == 2:
              Iphonelink = link['href']
              counter = counter + 1
          if counter == 1:
              Windowslink = link['href']
              counter = counter + 1   
          if counter == 0:
              Androidlink = link['href']
              counter = counter + 1
  
  
  url = 'https://traveler.pha.phila.gov:8443' + Androidlink
  print url
  
  
  import requests
  from requests.auth import HTTPDigestAuth
  r = requests.get(url,verify=False, auth=HTTPDigestAuth('username', 'password'))
  print len(r.content)
  </code></pre>
  
  <p>Second, My Wget Code, just download the html of the website. Aka not what i want</p>
  
  <pre><code>wget --no-check-certificate "https://traveler.pha.phila.gov:8443/servlet/traveler?action=GET&amp;deviceType=700&amp;address=https%3A%2F%2Ftraveler.pha.phila.gov%3A8443%2Fservlet%2Ftraveler&amp;userId=desantj&amp;redirectURL=%2Ftraveler%2FLotusTraveler%2Fandroid%2FLotusTraveler.apk" --http-user=username --http-passwd=password
  </code></pre>
  
  <p>If i can get either of them to retreive this file (APK File), I'd be overjoyed as I have easily wasted over 6 hours grinding on this</p>
  
  <p><em>Note</em> Username and passwords were concealed for security reasons </p>