|
@@ -6,7 +6,15 @@ use Dever;
|
|
|
|
|
|
class Import
|
|
|
{
|
|
|
- private $url = 'http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2020/';
|
|
|
+
|
|
|
+
|
|
|
+ private $url = 'http://www.stats.gov.cn/sj/tjbz/tjyqhdmhcxhfdm/2022/';
|
|
|
+
|
|
|
+ public function getUrl()
|
|
|
+ {
|
|
|
+ return $this->url;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 获取国家统计局最新的地区数据
|
|
|
*
|
|
@@ -18,9 +26,9 @@ class Import
|
|
|
|
|
|
$html = Dever::curl($url);
|
|
|
|
|
|
- $html = Dever::convert($html, "UTF-8", "GBK");
|
|
|
+
|
|
|
|
|
|
- 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;
|
|
|
|
|
@@ -61,9 +69,9 @@ class Import
|
|
|
|
|
|
$html = Dever::curl($url);
|
|
|
|
|
|
- $html = Dever::convert($html, "UTF-8", "GBK");
|
|
|
+
|
|
|
|
|
|
- preg_match_all('/<tr class=\'citytr\'><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><\/tr>/i', $html, $result);
|
|
|
+ preg_match_all('/<tr class="citytr"><td><a href="(.*?)">(.*?)<\/a><\/td><td><a href="(.*?)">(.*?)<\/a><\/td><\/tr>/i', $html, $result);
|
|
|
|
|
|
$update = array();
|
|
|
if (isset($result[3]) && isset($result[4]) && $result[4]) {
|
|
@@ -99,9 +107,9 @@ class Import
|
|
|
|
|
|
$html = Dever::curl($url);
|
|
|
|
|
|
- $html = Dever::convert($html, "UTF-8", "GBK");
|
|
|
+
|
|
|
|
|
|
- preg_match_all('/<tr class=\'countytr\'><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><td><a href=\'(.*?)\'>(.*?)<\/a><\/td><\/tr>/i', $html, $result);
|
|
|
+ preg_match_all('/<tr class="countytr"><td><a href="(.*?)">(.*?)<\/a><\/td><td><a href="(.*?)">(.*?)<\/a><\/td><\/tr>/i', $html, $result);
|
|
|
|
|
|
$update = array();
|
|
|
if (isset($result[3]) && isset($result[4]) && $result[4]) {
|
|
@@ -147,13 +155,13 @@ class Import
|
|
|
|
|
|
$html = Dever::curl($url);
|
|
|
|
|
|
- $html = Dever::convert($html, "UTF-8", "GBK");
|
|
|
+
|
|
|
}
|
|
|
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);
|
|
|
|
|
|
$update = array();
|
|
|
if (isset($result[3]) && isset($result[4]) && $result[4]) {
|
|
@@ -179,9 +187,9 @@ class Import
|
|
|
|
|
|
$html = Dever::curl($url);
|
|
|
|
|
|
- $html = Dever::convert($html, "UTF-8", "GBK");
|
|
|
+
|
|
|
|
|
|
- preg_match_all('/<tr class=\'villagetr\'><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td><\/tr>/i', $html, $result);
|
|
|
+ preg_match_all('/<tr class="villagetr"><td>(.*?)<\/td><td>(.*?)<\/td><td>(.*?)<\/td><\/tr>/i', $html, $result);
|
|
|
|
|
|
$update = array();
|
|
|
if (isset($result[1]) && isset($result[2]) && isset($result[3])) {
|