|
@@ -125,19 +125,39 @@ class Import
|
|
# 获取街道
|
|
# 获取街道
|
|
$this->getTown($province, $city, $id, $link . '/' . $result[3][$k]);
|
|
$this->getTown($province, $city, $id, $link . '/' . $result[3][$k]);
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ $city_info = Dever::db('area/city')->find(array('id' => $city, 'clear' => true));
|
|
|
|
+ $update['id'] = $city_info['id'];
|
|
|
|
+ $update['name'] = $city_info['name'];
|
|
|
|
+ $update['city_id'] = $city;
|
|
|
|
+ $update['province_id'] = $province;
|
|
|
|
+ $update['area'] = $province . ',' . $city;
|
|
|
|
+ $update['type'] = 1;
|
|
|
|
+ $update['level'] = 1;
|
|
|
|
+ $update['pinyin'] = $city_info['pinyin'];
|
|
|
|
+ $update['pinyin_first'] = $city_info['pinyin_first'];
|
|
|
|
+ $id = Dever::upinto('area/county', $update, $update);
|
|
|
|
+
|
|
|
|
+ # 获取街道
|
|
|
|
+ $this->getTown($province, $city, $id, false, $html);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public function getTown($province, $city, $county, $link)
|
|
|
|
|
|
+ public function getTown($province, $city, $county, $link = false, $html = false)
|
|
{
|
|
{
|
|
- $url = $this->url . $link;
|
|
|
|
|
|
+ if ($link) {
|
|
|
|
+ $url = $this->url . $link;
|
|
|
|
|
|
- $temp = explode('/', $link);
|
|
|
|
- $link = $temp[0] . '/' . $temp[1];
|
|
|
|
-
|
|
|
|
- $html = Dever::curl($url);
|
|
|
|
|
|
+ $temp = explode('/', $link);
|
|
|
|
+ $link = $temp[0] . '/' . $temp[1];
|
|
|
|
+
|
|
|
|
+ $html = Dever::curl($url);
|
|
|
|
|
|
- $html = mb_convert_encoding($html, "UTF-8", "GB2312");
|
|
|
|
|
|
+ $html = mb_convert_encoding($html, "UTF-8", "GB2312");
|
|
|
|
+ }
|
|
|
|
+ if (!$link && !$html) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
preg_match_all('/<tr class=\'towntr\'><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><\/tr>/i', $html, $result);
|
|
preg_match_all('/<tr class=\'towntr\'><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><\/tr>/i', $html, $result);
|
|
|
|
|