(.*?)<\/a><\/td><\/tr>/i', $html, $result);
$update = array();
if (isset($result[3]) && isset($result[4])) {
foreach ($result[4] as $k => $v) {
if ($v == '市辖区') {
$v = $province_name;
}
$update['id'] = $this->id($result[2][$k]);
$update['name'] = $v;
$update['province_id'] = $province;
$id = Dever::upinto('area/city', $update, $update);
# 获取县区
$this->getCounty($id, $result[3][$k]);
}
}
}
public function getCounty($city, $link)
{
$url = $this->url . $link;
$html = Dever::curl($url);
$html = mb_convert_encoding($html, "UTF-8", "GB2312");
preg_match_all('/(.*?)<\/a><\/td> | (.*?)<\/a><\/td><\/tr>/i', $html, $result);
$update = array();
if (isset($result[3]) && isset($result[4])) {
foreach ($result[4] as $k => $v) {
$update['id'] = $this->id($result[2][$k]);
$update['name'] = $v;
$update['city_id'] = $city;
Dever::upinto('area/county', $update, $update);
}
}
}
public function id($id)
{
return Dever::load('area/api')->code($id);
}
}
|