BS4
import bs4 import requests p = {'http': 'http://127.0.0.1:1080', 'https': 'http://127.0.0.1:1080'} r = requests.get(url="https://www.baidu.com", proxies=p) print(r.status_code) r.encoding = r.apparent_encoding soup = bs4.BeautifulSoup(r.text, 'lxml') with open("./aaabb.html", 'w', encoding='utf-8') as f: f.write(soup.prettify())