Can anyone provide a working urllib3 example that works? I have tried the example on the website https://pypi.org/project/urllib3/:
import urllib3
resp = urllib3.request("GET", "http://httpbin.org/robots.txt")
but keep on getting this error (using Python 3.10):
AttributeError: module 'urllib3.request' has no attribute 'Request'
The correct way to use urllib3 to send HTTP requests is slightly different
Make sure to install
urllib3if you haven't already by runningpip install urllib3.This code should work without errors and retrieve the
robots.txtfile fromhttp://httpbin.org/robots.txt.Ref: https://urllib3.readthedocs.io/en/stable/user-guide.html