Python爬虫 获取HTML源码 获取HTML源码 import requests url = 'https://www.baidu.com' headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"} html = requests.get(url,headers=headers) html.encoding='utf-8' print(html.text)