基于Python的反反爬虫技术分析与应用

2018-09-29 02:38:04余豪士匡芳君
智能计算机与应用 2018年4期
关键词:数据分析大数据

余豪士 匡芳君

摘 要:爬虫软件是现今互联网环境下,高效准确地获取数据的重要方式之一。针对传统的初级爬虫技术易于被目标网站拦截访问的问题,简述爬虫的工作原理和方式,讨论爬虫、反爬虫与反反爬虫之间的相互关系。分析应对目标网站的反反爬虫机制,包括伪装用户代理,设置IP地址代理、使用自动化测试工具调用浏览器等技术要点,并分析了基于Python语言中Requests库,构建了对网页的多种请求方式和数据获取方法的解决方案。结合反反爬虫机制与数据分析技术,以哔哩哔哩视频网为案例,分析其网页基本结构与调用的应用程序接口,使用Python与Requests库抓取网站所有视频的相关数据。数据清洗后分析播放量最高视频的相关信息,并将结论以数据可视化的方式呈现,实现对数据的获取、挖掘与分析。

关键词:网络爬虫; 反爬虫; 反反爬虫; 大数据; 数据分析

Abstract: Crawler software is one of the most important ways to obtain data effectively and accurately in the current Internet environment. In view of the traditional crawler technology which is prone to be intercepted by target website, the paper explains how the crawler appears to work, discusses about the relationship between crawler, anti-crawler and anti-anti-crawler, and analyzes the mechanism of anti-anti-crawler for the target website, including fake user agents, setting IP proxy address, calling browser using automated testing tools. Furthermore, multiple requests and data acquisition methods for web pages are built based on Requests Library in Python language and its solution is analyzed. Combined with the mechanism of anti-anti crawler and data analysis technology, the paper takes the Bilibili website as a case, analyzing its basic structure, as well as its API called. On the one side, all relevant data of video on the Bilibili website is captured using Python and Requests Library and the related information of the video, in which the highest click rate is analyzed after data cleaning. On the other side, the conclusion is presented in the way of data visualization, and the data acquisition, mining and analysis are also realized.

Key words: Web crawler; anti-crawler; anti-anti-crawler technology; big data; data analysis

引言

大數据时代下的数据来源和获取尤为重要[1],爬虫技术作为一项获取数据的工具而被广泛应用。已超过60%的互联网流量来自爬虫(Spider),各大搜索引擎门户网站以及新闻网站的文章都与爬虫息息相关。爬虫技术已成为当今的研究热点,目标网站对爬虫软件所做的各方面防范,给出了不同的拦截方式[2]。开发者与开发者之间通过爬虫、反爬虫、反反爬虫技术进行较量,一方面开发者想通过爬虫脚本获取数据,另一方面开发者又想拦截爬虫,防止爬虫脚本妨碍本网站的正常运营,对正常用户的访问造成了负面影响。……

登录APP查看全文

猜你喜欢
数据分析大数据
我校如何利用体育大课间活动解决男生引体向上这个薄弱环节
体育时空(2016年8期)2016-10-25 18:02:39
Excel电子表格在财务日常工作中的应用
浅析大数据时代背景下的市场营销策略
新常态下集团公司内部审计工作研究
中国市场(2016年36期)2016-10-19 04:31:23
浅析大数据时代对企业营销模式的影响
基于读者到馆行为数据分析的高校图书馆服务优化建议
科技视界(2016年22期)2016-10-18 14:37:36
大数据环境下基于移动客户端的传统媒体转型思路
新闻世界(2016年10期)2016-10-11 20:13:53
基于大数据背景下的智慧城市建设研究
科技视界(2016年20期)2016-09-29 10:53:22
数据+舆情:南方报业创新转型提高服务能力的探索
中国记者(2016年6期)2016-08-26 12:36:20