python最简单的爬虫——获取网页的html
            
            
              1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
   |  import requests
 
  url = 'http://www.baidu.com'
 
  headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",}
 
  response = requests.get(url,headers=headers)
 
  response.encoding = 'utf-8'
 
  html = response.text
 
  print(html)
 
 
  | 
 
