Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Request.get not working
#1
hi i'm new to python. I have just started learning requestsmodule.
I was able to successfully import requests module. But getting error while using requests.get command
I'm not able to execute basic commands. Need help plz guide me.

>>> import requests
>>> r=requests.get('https://www.google.com')
Error:
') Traceback (most recent call last): File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen chunked=chunked) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 344, in _make_request self._validate_conn(conn) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 843, in _validate_conn conn.connect() File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connection.py", line 370, in connect ssl_context=context) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\ssl_.py", line 355, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 407, in wrap_socket _context=self, _session=session) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 817, in __init__ self.do_handshake() File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 1077, in do_handshake self._sslobj.do_handshake() File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 689, in do_handshake self._sslobj.do_handshake() ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 449, in send timeout=timeout File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 641, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\retry.py", line 368, in increment raise six.reraise(type(error), error, _stacktrace) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\packages\six.py", line 685, in reraise raise value.with_traceback(tb) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen chunked=chunked) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 344, in _make_request self._validate_conn(conn) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connectionpool.py", line 843, in _validate_conn conn.connect() File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\connection.py", line 370, in connect ssl_context=context) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\urllib3\util\ssl_.py", line 355, in ssl_wrap_socket return context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 407, in wrap_socket _context=self, _session=session) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 817, in __init__ self.do_handshake() File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 1077, in do_handshake self._sslobj.do_handshake() File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 689, in do_handshake self._sslobj.do_handshake() urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<pyshell#27>", line 1, in <module> r=requests.get('https://www.google.com') File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\api.py", line 75, in get return request('get', url, params=params, **kwargs) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\api.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\sessions.py", line 646, in send r = adapter.send(request, **kwargs) File "C:\Users\ashabyrx\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\adapters.py", line 498, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
Reply
#2
are you behind proxy?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
thanks buran for the reply
I'm beginner to the python. Now started learning requests libraray
I just ran the above mentioned commands on python 3.6.8 IDLE.
I'm not getting expected results. ie immediately i'm ending up with error after r=requests.get('https://www.google.com').
please suggest me the solution
Reply
#4
I understand you are getting errors. That's why I ask if you are behind proxy. If you are behind proxy, you need to specify the proxy address in the get request.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how can I correct the Bad Request error on my curl request tomtom 8 4,969 Oct-03-2021, 06:32 AM
Last Post: tomtom
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 3,862 Jun-18-2020, 08:07 AM
Last Post: buran
  URLLIB.REQUEST Not Working hallofriends 1 6,354 Sep-18-2017, 05:00 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020