Request

Requests is an elegant and simple HTTP library for Python, built for human beings.

Make HTTP request

Create a new python file in your favorite text editor. Requests really make it easy for you so all you need to retrieve the HTML are a few lines of code:

import requests

URL = 'https://reporteri.net/zgjedhjet2021/'
page = requests.get(URL)

This snippet creates an HTTP request to the URL we gave it. It retrieves the HTML data that the server sends back and stores that data in a variable.

print(page)

If we use the python function to print out the variable to the console we will see the structure is the DOM of the website. Here is the definition if needed.

The Document Object Model (DOM) is a programming API for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. ... The Document Object Model can be used with any programming language.

Last updated