0

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.

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.

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

First up my python 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)

Second, My Wget Code, just download the html of the website. Aka not what i want

wget --no-check-certificate "https://traveler.pha.phila.gov:8443/servlet/traveler?action=GET&deviceType=700&address=https%3A%2F%2Ftraveler.pha.phila.gov%3A8443%2Fservlet%2Ftraveler&userId=desantj&redirectURL=%2Ftraveler%2FLotusTraveler%2Fandroid%2FLotusTraveler.apk" --http-user=username --http-passwd=password

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

Note Username and passwords were concealed for security reasons

4

1 回答 1

1

检查 wget -O LotusTraveler.apk "https://traveler.pha.phila.gov:8443/servlet/traveler?action=GET&deviceType=700&address=https%3A%2F%2Ftraveler.pha.phila.gov%3A8443%2Fservlet% 2Ftraveler&userId=desantj&redirectURL=%2Ftraveler%2FLotusTraveler%2Fandroid%2FLotusTraveler.apk" --http-user=username --http-passwd=password

**编辑:对不起,我应该读得更好。再次抱歉.. 虽然这不是问题原因,但我确实(通过谷歌)找到了许多类似/相同文件的下载位置

于 2013-01-24T21:46:42.723 回答