You need to use from urllib.request import urlopen, also I suggest you use the with statement while opening a connection.

from urllib.request import urlopen

with urlopen("https://sunlightlabs.github.io/congress/legislators?api_key='(myapikey)") as conn:
    # dosomething
Answer from Sede on Stack Overflow
🌐
Python
docs.python.org › 3 › library › urllib.html
urllib — URL handling modules
urllib — URL handling modules · | Theme · Auto · Light · Dark | Source code: Lib/urllib/ urllib is a package that collects several modules for working with URLs: urllib.request for opening and reading URLs · urllib.error containing the ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-urllib-module
Python Urllib Module - GeeksforGeeks
July 12, 2025 - Urllib package is the URL handling module for python. It is used to fetch URLs (Uniform Resource Locators).
🌐
urllib3
urllib3.readthedocs.io
urllib3 2.6.3 documentation
urllib3 is a powerful, user-friendly HTTP client for Python. Much of the Python ecosystem already uses urllib3 and you should too. urllib3 brings many critical features that are missing from the Py...
🌐
PyPI
pypi.org › project › urllib3
urllib3
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Python
docs.python.org › 3 › library › urllib.request.html
urllib.request — Extensible library for opening URLs
The urllib.request module defines functions and classes which help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more.
Find elsewhere
🌐
Oyoclass
docs.oyoclass.com › python3editor › modules › urllib
urllib - Python3 Editor Documentation
from urllib.request import urlopen import json ip = input("Input the IP you want to query: ") url = f"https://proxy.oyoclass.com/http://ip-api.com/json/{ip}" location = json.loads(urlopen(url).read()) print("Approx.
🌐
Real Python
realpython.com › ref › stdlib › urllib
urllib | Python Standard Library – Real Python
The Python urllib package is a collection of modules for working with URLs. It allows you to fetch data across the web, parse URLs, and handle various internet protocols.
🌐
W3Schools
w3schools.com › python › ref_module_urllib.asp
Python urllib Module
The urllib module is a package for working with URLs and making HTTP requests.
🌐
ArjanCodes
arjancodes.com › blog › using-python-urllib-module-for-web-scraping-and-url-parsing
Web Scraping and URL Parsing Made Easy with Python’s urllib | ArjanCodes
July 29, 2024 - Python’s urllib module is a powerful and versatile library for working with URLs and handling various internet-related tasks. It provides a range of functionalities, from fetching data from the web to parsing URLs.
🌐
GitHub
github.com › urllib3 › urllib3
GitHub - urllib3/urllib3: urllib3 is a user-friendly HTTP client library for Python · GitHub
urllib3 is a user-friendly HTTP client library for Python - urllib3/urllib3
Starred by 4K users
Forked by 1.3K users
Languages   Python
🌐
Scaler
scaler.com › topics › urllib-python
Urllib Python | Scaler Topics
May 4, 2023 - The urllib Python library is a built-in library that comes with the Python interpreter. It is a collection of various modules that helps us to work with the URLs (Uniform Resource Locator). The library uses the function urlopen() to fetch URLs using several protocols.
🌐
Reddit
reddit.com › r/python › requests vs. urllib: what problem does it solve?
r/Python on Reddit: Requests vs. urllib: What problem does it solve?
August 7, 2016 - This alone doesn't mean that urllib is bad, just that it's outdated. Similar functionality could easily be added, but I imagine they prefer the modularity of "use urllib to make the call" and "use json to load the data if it's in json format".
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python 3 tutorial › python 3 urllib
Python 3 URLlib | What is python 3 urllib? | Modules with Examples
March 30, 2023 - It’s used to get URLs from the Internet, it makes use of the URL open function to retrieve URLs over a variety of protocols. Urllib is a collection of modules for working with URLs, including URLs, urllib.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Nicolasbouliane
nicolasbouliane.com › blog › python-3-urllib-examples
Python 3 urllib examples - Nicolas Bouliane
from urllib.error import HTTPError import urllib.request try: response = urllib.request.urlopen('https://nicolasbouliane.com') response_status = response.status # 200, 301, etc except HTTPError as error: response_status = error.code # 404, 500, etc
🌐
Python Programming
pythonprogramming.net › urllib-tutorial-python-3
Python urllib tutorial for Accessing the Internet
The urllib module in Python 3 allows you access websites via your program. This opens up as many doors for your programs as the internet opens up for you. urllib in Python 3 is slightly different than urllib2 in Python 2, but they are mostly the same.
🌐
Python Module of the Week
pymotw.com › 3 › urllib.request › index.html
urllib.request — Network Resource Access
December 18, 2016 - The urllib.request module provides an API for using Internet resources identified by URLs.
🌐
Huihoo
docs.huihoo.com › python › 3.3.0 › library › urllib.html
21.5. urllib — URL handling modules — Python v3.3.0 documentation
urllib is a package that collects several modules for working with URLs: urllib.request for opening and reading URLs · urllib.error containing the exceptions raised by urllib.request · urllib.parse for parsing URLs · urllib.robotparser for parsing robots.txt files ·