Score
0
Watch 36 Star 97 Fork 33

RockYang / JAreaSelect-js省市区级联选择插件JavaScript

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
javascript 区域选择器, 省市区三级联动,做了select样式和仿京东样式的实现,数据是从京东抓取的,很全。 spread retract

Clone or download
spider.php 1.31 KB
Copy Edit Web IDE Raw Blame History
<?php
/**
* 地区采集器
*/
require 'php/mysql_class.php';
require 'php/mysql_config_class.php';
$mysql = mysql::getInstance();
$url = "https://d.jd.com/area/get?callback=getAreaListCallback";
$plist = $mysql->getList("select * from area");
foreach ($plist as $value) {
$data = file_get_contents($url."&fid={$value['id']}");
if ( $data ) {
$list = json_decode(rtrim(ltrim($data, "getAreaListCallback("), ")"), true);
foreach ($list as $val) {
$val['pid'] = $value['id'];
if ( $mysql->insert("area", $val) ) {
printf("插入数据 {$val['name']}\n");
}
sleep(1);//睡一秒
$tt = file_get_contents($url."&fid={$val['id']}");
if ( $tt ) {
$ttlist = json_decode(rtrim(ltrim($tt, "getAreaListCallback("), ")"), true);
foreach ($ttlist as $kk) {
$kk['pid'] = $val['id'];
if ($mysql->insert("area", $kk))
{
printf("插入数据 {$kk['name']}\n");
}
}
} else {
file_get_contents("a.log", "{$val['name']}", FILE_APPEND);
}
}
} else {
file_get_contents("a.log", "{$value['name']}", FILE_APPEND);
}
sleep(1);
}

Comment ( 0 )

Sign in for post a comment

JavaScript
1
https://gitee.com/blackfox/JAreaSelect.git
git@gitee.com:blackfox/JAreaSelect.git
blackfox
JAreaSelect
JAreaSelect-js省市区级联选择插件
master

Help Search