摘 要
Python为网页数据爬取和数据分析提供了很多工具包.基于Python的BeautifulSoup可以快速高效地爬取网站数据,Pandas工具能方便灵活地清洗分析数据,调用Python的Matplotlib工具包能便捷地把数据分析结果图形可视化.该文借助Python功能完备的标准库,强大的第三方库requests,BeautifulSoup以及正则表达式,通过编程完成对文件film.csv中电影信息数据的读取;对读取的数据进行清洗和整理;利用Bar函数编程输出影片的周平均票房(周平均票房指文件中的所有涉及城市周票房总平均),Y轴表示票房收入,单位万元;X轴表示电影名称。
通过matplotlib图形库以图形化的方式直观地展示数据结果,并加以分析,得出相关结论。该文研究为培养学生数据处理能力和可视化分析能力奠定了基础。
关键词:Python;爬虫;爬取;电影;数据
Abstract
Python provides many toolkits for web data crawling and data analysis. Python - based BeautifulSoup can quickly and efficiently crawl Web data, Pandas tools can easily and flexibly clean and analyze data, Calling the Python Matplotlib toolkit can easily visualize the data analysis results. Based on Python functional standard library, Powerful third-party library requests, BeautifulSoup and regular expressions, Complete the reading of movie information data in file film.csv by programming; Clean and organize the read data; By using the Bar function to program the output of the weekly average box office of the film (the weekly average box office refers to the total average of all the weekly box offices involved in the city), Y axis represents box office revenue, Unit 10,000 yuan; X axis represents the film name.
By matplotlib the graphic library to visualize the data results and analyze them, the relevant conclusions are drawn. This paper lays a foundation for cultivating students' data processing ability and visual analysis ability.
Keywords: Python; crawler; crawling; movie; data
目 录
摘 要 I
Abstract II
第1章 绪论 1
1.1 选题背景及意义 1
1.2 国内外研究现状 1
1.2.1 爬虫技术概述 1
1.2.2 爬虫设计者面临的问题与反爬虫技术现状 3
第2章 相关理论及技术 6
2.1 robot协议对本设计的影响 6
2.2 爬虫 6
2.2.1 工作原理 6
2.2.2 工作流程 7
2.2.3 抓取策略 7
2.3 Python及Pycharm简介 8
2.4运行环境和系统结构 8
第3章 系统设计 9
3.1环境搭建 9
3.2设计思路 9
3.3 第三方类库的简介和安装 10
3.3.1 Scarpy简介及安装 10
3.3.2 Numpy简介及安装 11
3.3.3 Pandas简介及安装 12
3.3.4 JieBa简介及安装 12
3.3.5 WordCloud简介及安装 12
3.3.6 Matplotlib简介及安装 12
3.3.7 Pygal简介及安装 12
3.3.8 re简介 13
3.3.9 json简介 13
3.3.10 os简介 13
3.3.11 shutil简介 13
3.3.12 pathlib简介 13
3.3.13 random简介 14
3.3.14 math简介 14
3.3.15 PIL简介 14
3.4 Scrapy详解 14
3.4.1 架构介绍 14
3.4.2 数据流 16
第4章 影视基本数据爬取 17
4.1爬取 17
4.2数据分析 19
4.2.1评分星级 19
4.2.2性别比例 21
4.2.3位置分布 23
4.2.4时评数量 26
4.2.5主要演员 27
4.2.6电影单元 29
4.3词云展示 30
4.3.1整体词云 30
4.3.2热评词云 32
4.4小结 34
总 结 35
致 谢 36
参考文献 37












