python爬虫微博数据可视化,词云
时间: 2023-08-23 12:11:46 浏览: 169
![ZIP](https://csdnimg.cn/release/download/static_files/pc/images/minetype/ZIP.png)
基于python爬取新浪微博爬虫以及生成词云源码.zip
![star](https://csdnimg.cn/release/wenkucmsfe/public/img/star.98a08eaa.png)
引用\[1\]:3.2.3 WordCloud
准备词云(使用爬取的book.db文件的instroduction字段进行分析)
#准备词云所需的文字(词)
con = sqlite3.connect('book.db')
cur = con.cursor()
sql = 'select instroduction from book250'
data = cur.execute(sql)
text = ""
for item in data:
text = text + item\[0\]
cur.close()
con.close()
#分词
cut = jieba.cut(text)
string = ' '.join(cut)
print(len(string))
#生成图片
img = Image.open(r'.\static\assets\img\tree.jpg') #打开遮罩图片
img_array = np.array(img) #将图片转换为数组
wc = WordCloud(
background_color='white',
mask=img_array,
font_path="msyh.ttc" # 生成字体
)
wc.generate_from_text(string) #绘制图片
fig = plt.figure(1)
plt.imshow(wc)
plt.axis('off') #是否显示坐标轴
plt.show() #显示生成的词云图片
问题: python爬虫微博数据可视化,词云
回答: 要实现python爬虫微博数据可视化并生成词云,你可以按照以下步骤进行操作。首先,你需要使用爬虫技术获取微博数据。然后,将获取到的微博文本进行分词处理,可以使用jieba库进行分词。接下来,将分词后的文本转换为字符串,并使用WordCloud库生成词云图。你可以选择一个合适的背景图片作为词云的形状,并设置字体等参数。最后,使用matplotlib库显示生成的词云图。这样就可以实现python爬虫微博数据可视化并生成词云了。
#### 引用[.reference_title]
- *1* [Python爬虫数据可视化之词云](https://blog.csdn.net/qq_55054495/article/details/119828798)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [python 爬虫与数据可视化](https://blog.csdn.net/kair_/article/details/107201859)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [python 爬虫及数据可视化展示](https://blog.csdn.net/ou_shen_xian/article/details/122874854)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文
相关推荐
![ipynb](https://img-home.csdnimg.cn/images/20210720083646.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)