One of the most common tasks when programming is accessing resources on the internet via URLs. As Python is a popular language for web development and automation, many wonder - is urllib built into Python for fetching URLs?
The answer is: sort of. There is a
The Urllib Module
Python does include a module called
import urllib.request
with urllib.request.urlopen('http://example.com') as response:
html = response.read()
print(html)
So in a way, urllib is part of Python. But it's not part of the Python standard library - it's an external module that gets bundled with Python installations by default.
The distinction here is that the Python standard library contains guaranteed built-in modules like
Urllib vs Requests
While
For example, to fetch a URL with Requests:
import requests
response = requests.get('http://example.com')
print(response.text)
So while