python3 sipder 01

简单实现一个获取网页

#coding:utf-8
from urllib import request

if __name__=='__main__':
	response = request.urlopen('http://www.csdn.net')
	html=response.read()
	print(html)

获取网页编码

#coding:utf-8
from urllib import request
import chardet

if __name__=='__main__':
	response = request.urlopen('http://www.csdn.net')
	html=response.read()
	charset = chardet.detect(html)
	print(charset)

猜你喜欢

转载自blog.csdn.net/ppwwp/article/details/83870781