python抓取百度首页的方法,python抓取首页
python抓取百度首页的方法,python抓取首页
本文实例讲述了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")
希望本文所述对大家的Python程序设计有所帮助。
相关内容
- Python中的rjust()方法使用详解,pythonrjust
- Python映射拆分操作符用法实例,python操作符
- 在Python中操作字符串之rstrip()方法的使用,pythonrstrip
- python实现提取百度搜索结果的方法,python百度搜索
- Python编程之属性和方法实例详解,python编程实例详解
- Python编程之多态用法实例详解,python多态
- python简单实现基数排序算法,python基数算法
- python实现合并两个数组的方法,python实现合并数组
- python中threading超线程用法实例分析,pythonthreading
- python中base64加密解密方法实例分析,pythonbase64
评论关闭