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

Python(2):Python获取网页信息

2017-10-10 15:10 218 查看
#coding=utf-8
import sys, urllib

url = "http://www.163.com" #网页地址

wp = urllib.urlopen(url) #打开连接

content = wp.read() #获取页面内容

fp = open("F:\\Python\\Project\\5getWebInfo\\web.txt","w") #打开一个文本文件

fp.write(content) #写入数据

fp.close() #关闭文件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: