人才搜索网站数据抓取原理与应用(附PPT,源代码)
原站著录信息
摘要
摘 要 当今人们要在互联网上快速获取所需要的信息,就会常常用到搜索引擎。搜索引擎并非在用户提交搜索关键字时才去搜索互联网,而是事先用一种叫“蜘蛛”的程序将可能被搜索的信息从互联网上抓取下来,整理并放在数据库里。用户提交搜索关键字后是在这个数据库里查找所要信息。本文通过一个人才搜索网站的实例,来论述蜘蛛抓取数据的原理,包括蜘蛛抓取数据的URL规则,正则表达式,搜索符合规则的URL的算法;并以一个简单的蜘蛛程序来演示其实现方法,其中要用到大量数据结构及相关算法,来实现HTML文件的解析,符合规则的URL的发现,数据的下…
摘 要
当今人们要在互联网上快速获取所需要的信息,就会常常用到搜索引擎。搜索引擎并非在用户提交搜索关键字时才去搜索互联网,而是事先用一种叫“蜘蛛”的程序将可能被搜索的信息从互联网上抓取下来,整理并放在数据库里。用户提交搜索关键字后是在这个数据库里查找所要信息。本文通过一个人才搜索网站的实例,来论述蜘蛛抓取数据的原理,包括蜘蛛抓取数据的URL规则,正则表达式,搜索符合规则的URL的算法;并以一个简单的蜘蛛程序来演示其实现方法,其中要用到大量数据结构及相关算法,来实现HTML文件的解析,符合规则的URL的发现,数据的下载。为了提高蜘蛛的工作效率,还用到了多线程,并论述了多线程之间的同步和互斥。这个蜘蛛程序的开发平台为Microsoft Visual Studio.net 2003。
关键词:蜘蛛; 数据抓取; URL规则; 正则表达式
Abstract
Nowadays, people always use search engines to get desired information quickly on the Internet. Before users input key words to use them, search engines would download potential information on the Internet by a program called “spider”, then sort and store it in the database. Therefore, when people post their key words, they are just search what they want in the database. Here a human resource search engine is taken as an example to show the principle of the spider, including the URL rules to downloading data, regular expression, algorithms to search URLs matching the rules. Then a simple spider program will be implemented, where a lot of data structures and algorithms will be used to parse HTML files, search URLs according rules and download data. In order to improve the speed of the spider, multi-threads technology is used, and the synchronism and mutual exclusion between multi-threads are discussed.
Key words:spider; data downloading; URL rule; regular epression
目 录
第一章 人才搜索网站的数据……………………………………1
1.1人才搜索网站数据的来源…………………………………………1
1.2人才网站数据存储形式……………………………………………1
1.3人才网站数据的抓取………………………………………………1
第二章 HTML文件……………………………………………… 2
2.1 HTML定义……………………………………………………………2
2.2 HTML语言的语法基础及规则………………………………………2
2.3 URL…………………………………………………………………2
2.4超链接………………………………………………………………2
第三章 正则表达式………………………………………………3
3.1正则表达式的定义…………………………………………………3
3.2正则表达式的扩展…………………………………………………4
3.3 URL的正则表达式规则……………………………………………5
第四章 蜘蛛工作原理……………………………………………6
第五章 多线程…………………………………………………8
5.1线程定义……………………………………………………………8
5.2多线程概念…………………………………………………………8
5.2.1多线程的优点……………………………………………………9
5.2.2多线程的缺点……………………………………………………9
5.3多线程的互斥与同步………………………………………………9
5.3.1同步(synchronism)…………………………………………9
5.3.2互斥(mutual exclusion)……………………………………10
5.3.3线程同步机制……………………………………………………11
第六章 蜘蛛试验版开发平台…………………………………13
6.1微软.NET平台……………………………………………………13
6.1.1公共语言运行库…………………………………………………14
6.1.2.NET Framework 类库…………………………………………15
6.2 C#语言……………………………………………………………16
6.2.1 C#语言功能……………………………………………………16
6.2.2使用C#语言的优越性…………………………………………16
6.3 开发环境——Visual Studio2003.NET…………………………17
第七章 .NET中的正则表达式与多线程………………………17
7.1 .NET中的正则表达式……………………………………………17
7.1.1正则表达式类……………………………………………………17
7.1.2 .NET中正则表达式的匹配行为………………………………19
7.2 .NET中的多线程…………………………………………………20
7.2.1线程处理类………………………………………………………21
第八章 试验版蜘蛛的实现……………………………………24
8.1试验版蜘蛛的核心数据结构………………………………………24
8.2试验版蜘蛛的模块与类……………………………………………24
8.2.1试验版蜘蛛的模块………………………………………………24
8.2.2试验版蜘蛛的类…………………………………………………25
8.3试验版蜘蛛中的多线程……………………………………………29
8.3.1线程概述…………………………………………………………30
8.3.2同步与互斥………………………………………………………30
第九章 结论……………………………………………………31
参考文献…………………………………………………………33
附录………………………………………………………………34
外文资料…………………………………………………………44
中文译文…………………………………………………………59
致谢……………………………………………………
全文与附件
提交申请后,可在会员中心查看原件和附件的查找进度。
