您的位置:首页 > 编程语言 > Python开发

Python3获取网页内容

2015-06-07 17:18 741 查看
import urllib.request
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0", "character":"utf-8"}
opener = urllib.request.build_opener()
opener.addheaders = [headers]
html = opener.open("http://blog.csdn.net/wskinght").read()
print(html.decode("utf-8"))


x = open("C:/cs.htm", encoding="utf-8").read()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: