通过本文主要向大家介绍了python教程百度云,python百度贴吧,python视频百度云,python百度百科,python百度云等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
本文实例讲述了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","C:\\url.txt")
</div>
希望本文所述对大家的Python程序设计有所帮助。
</div>
