Freitag, 30. August 2013, 14:26 Uhr

urllib unter Python 3 Debug-Meldungen entlocken

Im Grunde ganz simpel – vorausgesetzt, man weiss wie (angelehnt an how to debug a urllib.urlopen in python!, wo aber noch mit urllib unter Python 2 gearbeitet wird):

import urllib.request
import http.client

http.client.debuglevel = 1
http.client.HTTPConnection.debuglevel = 1

url = 'http://www.eMeidi.com/?action=hack'
headers = {}

Request = urllib.request.Request(url,None,headers)
response = urllib.request.urlopen(Request)	
html = response.read()

Dies produziert Ausgaben in folgender Form:

send: b'GET http://www.eMeidi.com/?action=hack HTTP/1.1\r\nAccept-Encoding: iden
tity\r\nHost: www.eMeidi.com\r\nUser-Agent: Python-urllib/3.3\r\nConnection: clo
se\r\n\r\n'
reply: 'HTTP/1.0 407 Proxy Authentication Required\r\n'
header: Date header: Proxy-Authenticate header: Proxy-Connection header: Content
-Type header: Content-Length

Tags: , ,
Labels: Programmierung

Kommentar erfassen