slav0nic
хз я юзаю стандартный питон с оффа)
чего и вам желаю, особенно прочтите;) http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/faq.html#ext_ssl
в активе его и нет)
Скачал с
python.org - начало работать..
Но проблемы есть:
import urllib2
import urllib
import httplib
from urlparse import urlparse
class MyHTTPRedirectHandler(urllib2.HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
pass
URLUser, URlPass = ‘', ’'
URL0 = '
https://service.skydsl.de/logon.php?L=en'
URL1 = '
https://service.skydsl.de/site/account.php'
URL2 = '
https://service.skydsl.de/site/credit.php'
url = URL0
scheme, domain, path, x1, x2, x3 = urlparse(url)
print 1
req = urllib2.Request(url=url)
print 2
handler = urllib2.HTTPBasicAuthHandler()
try:
print 3
req = urllib2.urlopen(req)
except urllib2.HTTPError, e:
print 4
realm_string = e.headers
q1 = realm_string.find('“')
q2 = realm_string.find('”', q1+1)
realm = realm_string
handler.add_password(realm, domain, URLUser, URlPass)
HTTPSh = urllib2.HTTPSHandler()
opener = urllib2.build_opener(handler, HTTPSh, MyHTTPRedirectHandler)
urllib2.install_opener(opener)
try:
print 5
req = urllib2.urlopen(req)
except urllib2.HTTPError, e:
try:
print 6
urllib2.urlopen(req)
except urllib2.HTTPError, e:
print 7
print req.read()
Мне надо залогинится на странице URL0 и последовательно скачать 2 страницы URL1 и URL2.
А оно в результате постоянно redirectit :-( :
1
2
3
send: 'GET /logon.php?L=en HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: service.skydsl.de\r\nConnection: close\r\nUser-agent: Python-urllib/2.4\r\n\r\n'
reply: 'HTTP/1.1 401 Authorization Required\r\n'
header: Date: Thu, 10 Aug 2006 11:24:23 GMT
header: Server: Apache
header: X-Powered-By: PHP/4.3.10
header: Cache-Control: private
header: Last-Modified: Thu, 10 Aug 2006 11:24:23 GMT
header: Pragma: no-cache
header: WWW-Authenticate: Basic realm="skyDSL Webserver"
header: Content-Length: 776
header: Connection: close
header: Content-Type: text/html; charset=iso-8859-1
4
5
send: 'GET /logon.php?L=en HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: service.skydsl.de\r\nConnection: close\r\nUser-agent: Python-urllib/2.4\r\n\r\n'
reply: 'HTTP/1.1 401 Authorization Required\r\n'
header: Date: Thu, 10 Aug 2006 11:24:25 GMT
header: Server: Apache
header: X-Powered-By: PHP/4.3.10
header: Cache-Control: private
header: Last-Modified: Thu, 10 Aug 2006 11:24:25 GMT
header: Pragma: no-cache
header: WWW-Authenticate: Basic realm="skyDSL Webserver"
header: Content-Length: 776
header: Connection: close
header: Content-Type: text/html; charset=iso-8859-1
send: 'GET /logon.php?L=en HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: service.skydsl.de\r\nConnection: close\r\nAuthorization: Basic \r\nUser-agent: Python-urllib/2.4\r\n\r\n'
reply: 'HTTP/1.1 302 Found\r\n'
header: Date: Thu, 10 Aug 2006 11:24:28 GMT
header: Server: Apache
header: X-Powered-By: PHP/4.3.10
header: Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
header: Last-Modified: Thu, 10 Aug 2006 11:24:28 GMT
header: Pragma: no-cache
header: Set-Cookie: SKYSESSION=4bf662e0c9b67c2ad8cf855ad1c8f3a8; path=/
header: Expires: Thu, 19 Nov 1981 08:52:00 GMT
header: Location: /site/index.php?L=en
header: Content-Length: 0
header: Connection: close
header: Content-Type: text/html; charset=iso-8859-1
6
send: 'GET /logon.php?L=en HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: service.skydsl.de\r\nConnection: close\r\nAuthorization: Basic \r\nUser-agent: Python-urllib/2.4\r\n\r\n'
reply: 'HTTP/1.1 302 Found\r\n'
header: Date: Thu, 10 Aug 2006 11:24:32 GMT
header: Server: Apache
header: X-Powered-By: PHP/4.3.10
header: Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
header: Last-Modified: Thu, 10 Aug 2006 11:24:32 GMT
header: Pragma: no-cache
header: Set-Cookie: SKYSESSION=94c00e6f33edcdcf08de7176fc858069; path=/
header: Expires: Thu, 19 Nov 1981 08:52:00 GMT
header: Location: /site/index.php?L=en
header: Content-Length: 0
header: Connection: close
header: Content-Type: text/html; charset=iso-8859-1
7
...