读书人

python抓取百度主页

发布时间: 2012-11-26 11:48:50 作者: rapoo

python抓取百度首页
import urllib
def downURL(url,filename):
try:
fp=urllib.urlopen(url)
except:
print('download error')
return 0
op=open(filename,'wb')
while 1:
s=fp.read()
if not s:
break
op.write(s)
fp.close()
op.close()
return 1
downURL("http://www.baidu.com","D:\\code\\url.txt")

读书人网 >perl python

热点推荐