Function in Python to extract web Data
Use Requests for HTTP and let it deal with the encoding
Do not bake the query into the URL string
Use BeautifulSoup for HTML parsing
Use typehints

Nice and simple:
from requests import get
from bs4 import BeautifulSoup


def get_cuit(dni: int) -&gt; str:
    with get(
        'https://www.cuitonline.com/search.php',
        params={'q': dni},
    ) as resp:
        resp.raise_for_status()
        doc = BeautifulSoup(resp.text, 'html.parser')

    span = doc.find('span', class_='cuit')
    return span.text


print(get_cuit(71_179_047))