1、摘要 摘要 网络爬虫是一种自动搜集互联网信息的程序。通过网络爬虫不仅能够为搜 索引擎采集网络信息,而且可以作为定向信息采集器,定向采集某些网站下的 特定信息,如招聘信息,租房信息等。 本文通过 JAVA 实现了一个基于广度优先算法的多线程爬虫程序。本论文 阐述了网络爬虫实现中一些主要问题:为何使用广度优先的爬行策略,以及如 何实现广度优先爬行;为何要使用多线程,以及如何实现多线程;系统实现过 程中的数据存储;网页信息解析等。 通过实现这一爬虫程序,可以搜集某一站点的 URLs,并将搜集到的 URLs 存入数据库。 【关键字】网络爬虫;JAVA;广度优先;多线程。 ABSTRACT II ABS
2、TRACT SPIDER is a program which can auto collect informations from internet. SPIDER can collect data for search engines, also can be a Directional information collector, collects specifically informations from some web sites, such as HR informations, house rent informations. In this paper, use JAVA
3、implements a breadth-first algorithm multi-thread SPDIER. This paper expatiates some major problems of SPIDER: why to use breadth-first crawling strategy, and how to implement breadth-first crawling; why to use multi-threading, and how to implement multi-thread; data structure; HTML code parse. etc.
4、 This SPIDER can collect URLs from one web site, and store URLs into database. 【KEY WORD】SPIDER; JAVA; Breadth First Search; multi-threads. 目录 第一章第一章 引言引言 1 1 第二章第二章 相关技术介绍相关技术介绍 2 2 2.1 JAVA 线程 2 2.1.1 线程概述 2 2.1.2 JAVA 线程模型. 2 2.1.3 创建线程 3 2.1.4 JAVA 中的线程的生命周期 4 2.1.5 JAVA 线程的结束方式 4 2.1.6 多线程同步 5 2.2 URL 消重. 5 2.2.1 URL 消重的意义. 5 2.2.2 网络爬虫 URL 去重储存库设计 5 2.2.3 LRU 算法实现 URL 消重. 7 2.3 URL 类访问网络. 8 2.4 爬行策略浅析 . 8 2.4.1 宽度或深度优先搜索策略. 8 2.4.2 聚焦搜索策略 9 2.4.3 基于内容评价的搜索策略. 9 2.4.4 基于链接结构评价的搜索策略 . 1