print("----------反扒-------------") #(headers req 反扒) url = 'https://www.cnblogs.com/'
# 用户代理 headers={"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 QIHU 360SE"}
# 构建请求对象 req=urllib.request.Request(url=url,headers=headers) # 用urlopen打开 resp = urllib.request.urlopen(req) # 从响应中获取数据 并且更改编码格式 html = resp.read().decode('utf-8') # 输出 print(html)