网络爬虫你知道多少?
2014-04-02 15:06
183 查看
网络爬虫是一个自动提取网页的程序,它为搜索引擎从万维网上下载网页,是搜索引擎的重要组成。传统爬虫从一个或若干初始网页的URL开始,获得初始网页上的URL,在抓取网页的过程中,不断从当前页面上抽取新的URL放入队列,直到满足系统的一定停止条件。下面展示实现蜘蛛捕捉的PHP代码。
如下:
再唠叨一句题外话,有个哥们喜欢玩LOL,特意的做了个网站www.qiduowan.com,想提高技术的赶紧去看看吧!
如下:
function get_naps_bot() { $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); if (strpos($useragent, 'googlebot') !== false){ return 'Googlebot'; } if (strpos($useragent, 'msnbot') !== false){ return 'MSNbot'; } if (strpos($useragent, 'slurp') !== false){ return 'Yahoobot'; } if (strpos($useragent, 'baiduspider') !== false){ return 'Baiduspider'; } if (strpos($useragent, 'sohu-search') !== false){ return 'Sohubot'; } if (strpos($useragent, 'lycos') !== false){ return 'Lycos'; } if (strpos($useragent, 'robozilla') !== false){ return 'Robozilla'; } return false; } function nowtime(){ $date=date("Y-m-d.G:i:s"); return $date; } $searchbot = get_naps_bot(); if ($searchbot) { $tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']); $url=$_SERVER['HTTP_REFERER']; $file="robotlog.txt"; $time=nowtime(); $data=fopen($file,"a"); fwrite($data,"Time:$time robot:$searchbot URL:$tlc_thispage "); fclose($data); }
再唠叨一句题外话,有个哥们喜欢玩LOL,特意的做了个网站www.qiduowan.com,想提高技术的赶紧去看看吧!
相关文章推荐
- 编程需要知道多少数学知识?
- Integer与int的种种比较你知道多少?
- C#中的枚举(Enum)你知道多少呢?
- 一个小程序,让你知道Qt一次能支持按下多少个键(二)
- 《奇妙的NULL值,你知道多少?》
- 网络中信息的传递与端口号你知道多少
- 数据库连接串你知道多少
- Http2.0你知道多少?
- sprintf,你知道多少?
- WinAPI你知道多少?!你知道几个!(e,废话一篇)
- 1-20的两个数把和告诉A,积告诉B,A说不知道是多少,B也说不知道,这时A说我知道了,B说我也知道了,请你猜猜这两个数的和是多少
- 【专题】关于敏捷测试,我们到底知道多少?
- 关于符号位扩展你又知道多少
- 油管年度回顾视频堪比新闻联播,17年度梗你知道多少?
- sprintf,你知道多少?
- UIView 你知道多少
- 广州APP开发多少钱一个呢,品向告诉你知道
- Integer与int的种种比较你知道多少?
- 类型构造器(静态构造函数)的执行时机你知道多少?
- 网络营销的关键你知道多少