|
@@ -22,6 +22,8 @@ class Import
|
|
|
|
|
|
preg_match_all('/<td><a href=\'(.*?)\'>(.*?)<br\/><\/a><\/td>/i', $html, $result);
|
|
preg_match_all('/<td><a href=\'(.*?)\'>(.*?)<br\/><\/a><\/td>/i', $html, $result);
|
|
|
|
|
|
|
|
+ Dever::config('base')->hook = true;
|
|
|
|
+
|
|
# 获取省份
|
|
# 获取省份
|
|
$this->getProvince($result);
|
|
$this->getProvince($result);
|
|
|
|
|
|
@@ -68,12 +70,12 @@ class Import
|
|
$id = Dever::upinto('area/city', $update, $update);
|
|
$id = Dever::upinto('area/city', $update, $update);
|
|
|
|
|
|
# 获取县区
|
|
# 获取县区
|
|
- $this->getCounty($id, $result[3][$k]);
|
|
|
|
|
|
+ $this->getCounty($province, $id, $result[3][$k]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public function getCounty($city, $link)
|
|
|
|
|
|
+ public function getCounty($province, $city, $link)
|
|
{
|
|
{
|
|
$url = $this->url . $link;
|
|
$url = $this->url . $link;
|
|
|
|
|
|
@@ -92,16 +94,40 @@ class Import
|
|
$update['id'] = $this->id($result[2][$k]);
|
|
$update['id'] = $this->id($result[2][$k]);
|
|
$update['name'] = $v;
|
|
$update['name'] = $v;
|
|
$update['city_id'] = $city;
|
|
$update['city_id'] = $city;
|
|
|
|
+ $update['province_id'] = $province;
|
|
|
|
+ $update['area'] = $province . ',' . $city;
|
|
|
|
+ $num = substr($update['id'], 4);
|
|
|
|
+
|
|
|
|
+ # type = 1城区 2郊区 3县城 4经济技术开发 5县级市
|
|
|
|
+ if ($v == '门头沟区') {
|
|
|
|
+ $update['type'] = 2;
|
|
|
|
+ $update['level'] = 2;
|
|
|
|
+ } elseif ($num <= 10) {
|
|
|
|
+ $update['type'] = 1;
|
|
|
|
+ $update['level'] = 1;
|
|
|
|
+ } elseif ($num > 10 && $num <= 20) {
|
|
|
|
+ $update['type'] = 2;
|
|
|
|
+ $update['level'] = 2;
|
|
|
|
+ } elseif ($num > 20 && $num <= 70) {
|
|
|
|
+ $update['type'] = 3;
|
|
|
|
+ $update['level'] = 3;
|
|
|
|
+ } elseif ($num > 70 && $num <= 80) {
|
|
|
|
+ $update['type'] = 4;
|
|
|
|
+ $update['level'] = 2;
|
|
|
|
+ } elseif ($num >= 80) {
|
|
|
|
+ $update['type'] = 5;
|
|
|
|
+ $update['level'] = 2;
|
|
|
|
+ }
|
|
$this->pinyin($update);
|
|
$this->pinyin($update);
|
|
$id = Dever::upinto('area/county', $update, $update);
|
|
$id = Dever::upinto('area/county', $update, $update);
|
|
|
|
|
|
# 获取街道
|
|
# 获取街道
|
|
- $this->getTown($id, $link . '/' . $result[3][$k]);
|
|
|
|
|
|
+ $this->getTown($province, $city, $id, $link . '/' . $result[3][$k]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public function getTown($county, $link)
|
|
|
|
|
|
+ public function getTown($province, $city, $county, $link)
|
|
{
|
|
{
|
|
$url = $this->url . $link;
|
|
$url = $this->url . $link;
|
|
|
|
|
|
@@ -120,16 +146,19 @@ class Import
|
|
$update['id'] = $this->id($result[2][$k], 9);
|
|
$update['id'] = $this->id($result[2][$k], 9);
|
|
$update['name'] = $v;
|
|
$update['name'] = $v;
|
|
$update['county_id'] = $county;
|
|
$update['county_id'] = $county;
|
|
|
|
+ $update['city_id'] = $city;
|
|
|
|
+ $update['province_id'] = $province;
|
|
|
|
+ $update['area'] = $province . ',' . $city . ',' . $county;
|
|
$this->pinyin($update);
|
|
$this->pinyin($update);
|
|
$id = Dever::upinto('area/town', $update, $update);
|
|
$id = Dever::upinto('area/town', $update, $update);
|
|
|
|
|
|
# 获取社区
|
|
# 获取社区
|
|
- //$this->getVillage($id, $link . '/' . $result[3][$k]);
|
|
|
|
|
|
+ //$this->getVillage($province, $city, $county, $id, $link . '/' . $result[3][$k]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public function getVillage($town, $link)
|
|
|
|
|
|
+ public function getVillage($province, $city, $county, $town, $link)
|
|
{
|
|
{
|
|
$url = $this->url . $link;
|
|
$url = $this->url . $link;
|
|
|
|
|
|
@@ -146,6 +175,10 @@ class Import
|
|
$update['code'] = $result[2][$k];
|
|
$update['code'] = $result[2][$k];
|
|
$update['name'] = $v;
|
|
$update['name'] = $v;
|
|
$update['town_id'] = $town;
|
|
$update['town_id'] = $town;
|
|
|
|
+ $update['county_id'] = $county;
|
|
|
|
+ $update['city_id'] = $city;
|
|
|
|
+ $update['province_id'] = $province;
|
|
|
|
+ $update['area'] = $province . ',' . $city . ',' . $county . ',' . $town;
|
|
$this->pinyin($update);
|
|
$this->pinyin($update);
|
|
Dever::upinto('area/village', $update, $update);
|
|
Dever::upinto('area/village', $update, $update);
|
|
}
|
|
}
|