urllib.request实现网络爬虫-网面抓取

root
abc abc
  • 15 Jul

import urllib.request
url = 'https://www.ruc.edu.cn/'
headers = {'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36'}
req = urllib.request.Request(url=url, headers=headers)
html = urllib.request.urlopen(req)
print(html.read().decode('utf-8'))