python抓取数据步骤

时间:2021-10-05 08:31:39

#-------PYTHON获取网页内容-------------#

import sys, urllib

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

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

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

fp = open("/home/cx/content.txt","w") #打开一个文本文件

fp.write(content) #写入数据

fp.close() #关闭文件



http://www.lupaworld.com/portal.php?mod=view&aid=239158&page=all

http://www.open-open.com/lib/view/open1346166586770.html

http://wuyanzan60688.blog.163.com/blog/static/1277761632011104101010749/

http://www.2cto.com/kf/201403/285930.html