网络爬虫你知道多少?
来源:互联网 发布:淘宝供销平台一件代发 编辑:程序博客网 时间:2024/04/30 18:50
网络爬虫是一个自动提取网页的程序,它为搜索引擎从万维网上下载网页,是搜索引擎的重要组成。传统爬虫从一个或若干初始网页的URL开始,获得初始网页上的URL,在抓取网页的过程中,不断从当前页面上抽取新的URL放入队列,直到满足系统的一定停止条件。下面展示实现蜘蛛捕捉的PHP代码。
如下:
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,想提高技术的赶紧去看看吧!
0 0
- 网络爬虫你知道多少?
- 网络爬虫知多少
- 2007年网络名言100句你知道多少?
- sprintf,你知道多少?
- sprintf,你知道多少?
- sprintf,你知道多少
- sprintf你知道多少
- sprintf你知道多少
- spirntf,你知道多少?
- spirntf,你知道多少?
- spirntf,你知道多少?
- sprintf你知道多少
- sprintf你知道多少
- sprintf你知道多少
- sprintf 你知道多少?
- sprintf,你知道多少?
- sprintf,你知道多少?
- sprintf你知道多少
- 非比例合约分保
- 修改MyEclipse的maven仓库路径
- SendMessage、PostMessage原理
- dom4j解析xml字符串实例
- APP开发新手应该知道的5件事
- 网络爬虫你知道多少?
- servlet 重定向(redirect)
- win7 安装 Android Studio
- openstack中的高可用介绍
- 使用dom4j解析XML例子
- 删除二叉树中的度数为1的所有结点
- 1 How the GNU Radio scheduler iscalled and what it does
- 使用dom4j和XPath解析XML之例子二
- net ToString格式(转载)