爬虫爬取文字生成词云

import requests
import re
import wordcloud
import imageio
import jieba
response = requests.get('http://www.haha56.net/xiaohua/gushi/list_1_2.html')
response.encoding='gbk'
data = response.text
data_result = re.findall('

(.*?)',data)
data_result_str = ''.join(data_result)
w = wordcloud.WordCloud(font_path=r'C:\Windows\Fonts\微软雅黑\msyhbd') ##选择字体
w.generate(data_result_str)
w.to_file('outfile.png') ##输出png

爬虫爬取文字生成词云_第1张图片

转载于:https://www.cnblogs.com/oxtime/p/11227849.html

你可能感兴趣的:(爬虫爬取文字生成词云)