<?php
require 'vendor/autoload.php';
use QL\QueryList;
header('Content-type:text/html;charset=utf-8');
$offset=1;
for($i=1;$i<=33;$i++){
$url = "http://bj.qizuang.com/company/?p=".$offset;
$html = file_get_contents($url);
//采集规则
$rules = [
//采集a标签的href属性
'url' => ['.company-link','href','',function($content){
return $content;
}],
];
$ql = QueryList::html($html)->range('.new-box-l>ul>li')->rules($rules)->query();
$data = $ql->getData();
foreach ($data->all() as $key => $val) {
getContents($val['url']);
}
$offset+=1;
echo "弟".($i+1)."页完成".PHP_EOL;
}
function getContents($url){
$html = file_get_contents($url);
//采集规则
$rules = [
//采集a标签的href属性
'title' => ['.com-tit','text'],
'logo' => ['.c-mark img','src'],
'address' => ['.att','text'],
'telphone'=>['.tel','text'],
'mobile'=>['.mob','text'],
];
$ql = QueryList::html($html)->rules($rules)->query();
$data = $ql->getData();
$data = $data->first();
}
打开App,阅读手记