(.*?)<\/td> | (.*?)<\/td> | (.*?)<\/td><\/tr>/i', $html, $result);
$update = [];
if (isset($result[1]) && isset($result[2]) && isset($result[3])) {
foreach ($result[3] as $k => $v) {
$update['id'] = $this->id($result[1][$k], 12);
$update['code'] = $result[2][$k];
$update['name'] = strip_tags($v);
$update['town_id'] = $town;
$update['county_id'] = $county;
$update['city_id'] = $city;
$update['province_id'] = $province;
$update['area'] = $province . ',' . $city . ',' . $county . ',' . $town;
$update = Dever::load('data', 'area')->pinyin($update);
$this->up('village', $update['id'], $update);
}
}
}
private function html($url)
{
$html = Dever::curl($url)->result();
//$html = Dever::convert($html, "UTF-8", "GBK");
$html = preg_replace('//', '', $html); // 去掉HTML注释
$html = preg_replace('/\s+/', ' ', $html); // 清除多余的空格
$html = preg_replace('/>\s', '><', $html); // 去掉标记之间的空格
return $html;
}
}
|