APP下载

基于Scrapy框架的分布式网络爬虫系统设计与实现

2021-04-03周毅李威何金程蕾柳璐

现代信息科技 2021年19期

周毅 李威 何金 程蕾 柳璐

摘  要:针对传统单机网络爬虫抓取效率低、稳定性差、数据量少等问题,文章利用Scrapy框架结合Redis技术,对传统网络爬虫框架进行改进和优化,设计出了分布式非结构化的网络爬虫系统,使采集到的信息能以非结构化形式存储于MongoDB数据库内,实现对数据信息的实时、有效处理分析。经过实际应用测试,证明基于Scrapy框架的分布式非结构化网络爬虫系统相较于传统单机系统具有更高的效率。

关键词:分布式;Scrapy框架;网络爬虫

中图分类号:TP311                 文献标识码:A文章编号:2096-4706(2021)19-0043-04

Design and Implementation of Distributed Web Crawler System Based

On Scrapy Framework

ZHOU Yi, LI Wei, HE Jin, CHENG Lei, LIU Lu

(Information and Communication Branch of State Grid Liaoning Electric Power Supply Co., Ltd., Shenyang  110055, China)

Abstract:Aiming at the problems of low capture efficiency, poor stability and small amount of data on traditional single-machine web crawler, this paper uses Scrapy framework and Redis technology to improve and optimize the traditional web crawler framework, and designs a distributed and unstructured web crawler system, which enables the collected information to be stored in the MongoDB database in an unstructured form, so as to achieve real-time and effective processing and analysis of data information. After practical application test, it is proved that the distributed and unstructured web crawler system based on Scrapy framework has higher efficiency than the traditional single-machine system.

Keywords: distributed; Scripy framework; Web crawler

0  引  言

隨着大数据时代的到来,人们对数据的需求与日俱增。为了对万维网上的数据进行特定的搜索,各种搜索引擎也是层出不穷,搜索引擎在数据搜集中站着越来越重要的地位,但正是因为信息的高速发展,用户对信息的搜索也是越来越严苛,如今的搜索引擎也越来越难以满足用户的需求[1]。因此,互联网数据的搜集成为当代科技必不可少的技术之一,网络爬虫技术应运而生。网络爬虫技术能够实现互联网信息的自动化搜集,并将相关信息存入数据库内部。但传统单机网络爬虫抓取效率低、稳定性差、数据量少,不能满足大数据时代下的数据需求;针对开源爬虫方面,虽然已研发出Nutch、Larbin等网络爬虫项目,但普遍存在运行效率低、稳定性差、不支持中文等问题。因此本文提出基于Scrapy框架的分布式网络爬虫系统。

1  相关原理与技术

1.1  网络爬虫

网络爬虫(Web Crawler),又称为网络蜘蛛(Web Spider)或Web信息采集器,是一个自动下载网页的计算机程序或自动化脚本,是搜索引擎的重要组成部分[2]。……

登录APP查看全文