OVH Cloud OVH Cloud

httplib error

1 réponse
Avatar
Yves Lange
def getweb(sUrl, sPage='index.html'):
from httplib import HTTP
h = HTTP(sUrl)
h.putrequest('GET', sPage)
h.putheader('Accept', 'text/html')
h.putheader('Accept', 'text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
if errcode == 200:
f = h.getfile()
f=f.read()
else:
print str(errcode)+"\nLa page est introuvable, attention aux
redirections !"
sys.exit

>>> ça ne marche pas quand j'utilise: getweb('www.hacktinium.com',
'index.php') pourquoi ? merci ;)

1 réponse

Avatar
Yves Lange
def getweb(sUrl, sPage='index.html'):
from httplib import HTTP
h = HTTP(sUrl)
h.putrequest('GET', sPage)
h.putheader('Accept', 'text/html')
h.putheader('Accept', 'text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
if errcode == 200:
f = h.getfile()
f=f.read()
else:
print str(errcode)+"nLa page est introuvable, attention aux
redirections !"
sys.exit

ça ne marche pas quand j'utilise: getweb('www.hacktinium.com',
'index.php') pourquoi ? merci ;)



Utilisez urllib à la place ;)