代码有点多放在我的github上
https://github.com/longsongline/douban-bigdata-showhttps://github.com/longsongline/douban-bigdata-show
使用具体流程1.先运行dashuju3.py
这个是用于爬取的豆瓣top250的代码,会生成一个csv文件
1.import requests
2.import bs4
3.import csv
4.
5.from lxml import etree
6.import requests
7.import time
8.import os
9.
10.import datetime
11.import time
12.#创建或者写入csv
13.csv_file=open('dashuju250.csv', 'w', newline='',encoding='utf-8')
14.writer = csv.writer(csv_file)
15.#列名添加
16.writer.writerow(['No', 'name', 'score', 'recommendation', 'yanyuan','daoyan','year','country','classes'])
17.#请求头越猛越好,反正这个豆瓣就是让你爬的,不用那么多也行
18.headers = {
19. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36',
20. 'Cookie': 'lang=zh-cn; theme=default; ajax_lastNext=on; selfClose=1; bugModule=0; bugBranch=0; treeBranch=0; moduleBrowseParam=0; openApp=qa; windowWidth=659; windowHeight=706',
21. }
22.#因为有十个页面,所以目前采用分别爬取
23.for x in range(10):
24. #每一个的连接
25. url = 'https://movie.douban.com/top250?start=' + str(x*25) + '&filter='
26. res = requests.get(url, headers=headers)
27. #靓汤出马
28. bs = bs4.BeautifulSoup(res.text, 'html.parser')
29. bs = bs.find('ol', class_="grid_view")
30. #就打开f12找需要的东西的
这个文件想直接获取的话就下载就行了
这样就可以省去这一步
https://download.csdn.net/download/long_songs/85406980https://download.csdn.net/download/long_songs/85406980
2.运行ciyun.py
制作词云
这一步,如果也不想做,直接把图片偷走就好了
然后再换底运行
3.huandi.py
换成蓝色的底部,因为我的可视化的色调是蓝色的
4.布置准备好,替换好路径后,运行app.py 的flask,打开网址即可显示出你的高档可视化成果啦!
有什么问题可以留言或者私信我



