# -*- coding: utf-8 -*- import urllib2
import re
import time
import jieba url="http://www.baidu.com"
html=urllib2.urlopen(url).read()
html=unicode(html,'utf-8')
word=re.findall(ur"[\u4e00-\u9fa5]+",html) s=""
for w in word:
s+=w seg_list=jieba.cut(s,cut_all=False)
fenci="/ ".join(seg_list)
print 'get web-->',s
print 'div result-》',fenci
time.sleep(10)
其中使用了 urllib2 re jieba三个模块 第一个模块用于获得网页内容,第二个模块用正则表达式提取中文字符 第三个模块用于分词
参考:
http://www.cnblogs.com/mmix2009/p/3220427.html
【附】安装python模块将其下载后将对应的文件夹拷入python安装目录下的 Lib/site-packages/ 下