Estoy trabajando con clases, y estoy haciendo una clase para manejar request.
La clase es asi:
Clase Request: request.py
Código:
Programa principal de prueba: testing.pyimport requests class Request: #attributes url = "" def __init__(self,url): self.url = url def get_contents(self): #Realiza request y devuelve contenido r = requests.get(self.url) return r.content def show_url(self): print "URL Base: ", self.url
Código:
Cuando ejecuto esto , me tira el siguiente error:from request import Request r = Request("htt://www.forosdelweb.com/") ret = r.get_contents() print "Contenido:" print ret
Código:
Parece simple lo que quiero hacer, pero me tira este error y no puedo seguir de este paso .Traceback (most recent call last): File "testing.py", line 6, in <module> ret = r.get_contents() File "/home/userx/Envs/hu_selenium/request.py", line 12, in get_contents r = requests.get(self.url) File "/home/userx/Envs/hu_selenium/local/lib/python2.7/site-packages/requests/api.py", line 59, in get return request('get', url, **kwargs) File "/home/userx/Envs/hu_selenium/local/lib/python2.7/site-packages/requests/api.py", line 48, in request return session.request(method=method, url=url, **kwargs) File "/home/userx/Envs/hu_selenium/local/lib/python2.7/site-packages/requests/sessions.py", line 451, in request resp = self.send(prep, **send_kwargs) File "/home/userx/Envs/hu_selenium/local/lib/python2.7/site-packages/requests/sessions.py", line 551, in send adapter = self.get_adapter(url=request.url) File "/home/userx/Envs/hu_selenium/local/lib/python2.7/site-packages/requests/sessions.py", line 630, in get_adapter raise InvalidSchema("No connection adapters were found for '%s'" % url) requests.exceptions.InvalidSchema: No connection adapters were found for 'htt://www.forosdelweb.com'
Alguna idea??
Gracias de antemano.