import urllib.request
import http.cookiejar
def request(url,headers):
'''
两个参数
:param url:统一资源定位符,请求网址
:param headers:请求头
:return:html
'''
# ***************** Begin ******************** #
cookie = http.cookiejar.CookieJar()
handler = urllib.request.HTTPCookieProcessor(cookie)
opener = urllib.request.build_opener(handler)
r= opener.open(url)
# ***************** End ******************** #
html = r.read().decode('utf-8')
return html
头歌urllib爬虫-第二关
最新推荐文章于 2025-01-21 17:31:23 发布