[PYTHON] Pegar HTML de um site com Python

import httpx
from bs4 import BeautifulSoup

request = httpx.get("https://site-url.com")
soup = BeautifulSoup(request, 'html.parser')

print(soup.prettify())

Salvar em arquivo:

with open(f"nome_do_arquivo.txt", "a") as arq:
    arq.write(soup.prettify())

tu também pode usar a biblioteca requests

import requests
from bs4 import BeautifulSoup

url = str(input("Digite a url: ")

html = requests.get(url)

soup = BeautifulSoup(html, "html5lib")

html_treated = soup.prettify()

print(html_treated)