简易爬虫示例程序

root
abc abc
  • 25 Jul

import urllib.request
url = 'http://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'))

root moved this 3 months, 2 weeks ago