编写一个网络蜘蛛,须要节制以下知识:
1、网络编程:利用PHP的cURL扩展库,仿照HTTP要求、吸收相应数据;
2、HTML解析:利用PHP的DOM扩展库或其他HTML解析工具,解析网页构造,取出所需数据;

3、数据存储:利用PHP的文件操作、数据库操作等技能,将获取到的数据存储在本地或远程做事器中。
下面是一个大略的网络蜘蛛示例:
<?php//定义目标网页地址$url = 'http://www.example.com/index.html';//定义cURL句柄$ch = curl_init();//设置cURL参数curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HEADER, false);//实行cURL要求$content = curl_exec($ch);//关闭cURL句柄curl_close($ch);//解析HTML代码$dom = new DOMDocument();@$dom->loadHTML($content);//取出所需数据$links = $dom->getElementsByTagName('a');foreach ($links as $link) { $url = $link->getAttribute('href'); $text = $link->nodeValue; echo $text . ' -> ' . $url . "\n";}