urllib get in python

You can use the urllib module in python to make HTTP GET requests. Here is an example:

main.py
import urllib.request

response = urllib.request.urlopen('https://www.google.com')
html = response.read()
print(html)
118 chars
6 lines

In the above example, we first import the urllib.request module. Then, we make a GET request to the URL https://www.google.com using the urlopen() method. This method returns a response object, which we can read using the read() method. Finally, we print the HTML of the page.

Note that you can also pass additional parameters to the urlopen() method, such as headers or data for a post request.

related categories

gistlibby LogSnag