本文实例讲述了python采集百度百科的方法。分享给大家供大家参考。具体如下:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#encoding=utf-8
#Filename:get_baike.py
import urllib2,re
import sys
def getHtml(url,time=10):
response = urllib2.urlopen(url,timeout=time)
html = response.read()
response.close()
return html
def clearBlank(html):