最近雨下得厉害,闲的百无聊赖,遂萌生码码最近看的《Webbots、Spiders 和 Screen Scrapers》的想法~~~
一下正文:
----------------------------------------------------------------------------------------------------------------------------------------------------------------
由于,初次接触PHP。不知配置的PHP的生猛,一连上网找了许多的资料。几经测试都是失败,后来试了wamp。(慕课上有教程的)nice!终于可以了!那个激动得!
还要说说本书含的LIB库。先从本书官网上下载该库,解压到任意路径。记住!
0x01 LIB_http定义了以下的默认变量
可以在源代码中修改
define("WEBBOTS_NAME","Test Webbot");
define("CURL_TIMEOUT",25);
define("COOKIE_FILE","c:\cookie.txt");
事实上,这个库只是curl的封装,更便于使用。
0x02 使用LIB_parse,获取特定html标签
<?php
include("D:\wamp\bin\php\php5.5.12\include\LIB_parse.php");
include("D:\wamp\bin\php\php5.5.12\include\LIB_http.php");
$web_page = http_get($target = "www.baidu.com",$referer ="");
$meta_tag_array = parse_array($web_page['FILE'],"<img",">");
for($xx = 0; $xx<count($meta_tag_array);$xx++)
{
echo $meta_tag_array[$xx]."\n";
$name = get_attribute($meta_tag_array[$xx],$attribute="src");
echo $name ."\n";
}
?>