Goutte的基本使用最近在工作中使用了PHP爬虫框架Goutte(号称PHP上最好的爬虫框架)。在这里把自己用过的使用技巧记下来,以免下次使用时摸索。表格相关html:国内高隐代理IP
更多
国家代理IP地址 | 端口 | 服务器地址匿名类型 | 生存时间验证时间175.155.24.112 | 808 | 四川德阳 | 高尼HTTP | 3小时 | 1分钟前 | php:1.解析td$cr的内容awler->filter('table#ip_list>tr')->each(function(Crawler$node,$i){$ip=$node->filter('td')->each(function(Crawler$node_ip,$node_ip_num){$text=trim($node_ip->text());if(empty($text)&&$node_ip_num>0&&!empty(trim($node_ip->html()))){$text=$node_ip->filter('div')->attr('title');}return$text;});return$ip;});}2。按位置匹配td标签$td=$crawler->filter('td')->eq(1)->text();匹配两个classhtml:php:$crawler->filter('div.class1.class1');匹配idhtml:php:$crawler->filter('div#hello');imagehtml:php:$crawler->filter('img')->attr('src');内嵌html我经常用这个来检查匹配规则是否正确html:Helloworld
php:$crawler->filter('catchMeIfYouCan')->html();部分原创,部分参考本博客