Python3 网络爬虫入门知识碎片

step1 下载网页源代码

# -*- coding: utf-8 -*-
import urllib.request
url1="http://www.guoxue123.com/"
cc="index"
url2=".html"
url=url1+cc+url2
request=urllib.request.Request(url)
response=urllib.request.urlopen(request)
skb=response.read().decode('gbk')
#skb=skb.encode('latin-1').decode('unicode_escape')
#skb=skb.decode('gbk').encode('utf-8')
print(skb)

你可能感兴趣的:(Python,python,网络爬虫,utf-8,url)