function test()
{
$a = [
1939165,
1935657,
];
$b = array_unique($a);
$c = array_diff_assoc($a, $b);
if ($c) {
echo var_export($c, 1) . PHP_EOL;
}
$provinces = [
'山东','江苏','安徽','四川','陕西','湖北','北京','天津','上海','广东','广西','浙江','河南','甘肃','吉林',
'辽宁','内蒙古','新疆','黑龙江','福建','河北','重庆','海南','江西','山西','湖南','青海','贵州','宁夏','云南','西藏'
];
$i = 0;
$count = count($b);
foreach ($b as $item) {
$i++;
$url = 'https://www.chahaoba.com/search_es?input=' . $item;
$html = file_get_contents($url);
$reg1 = "/<a .*?>(.*?)<\/a>/";
preg_match('/<li>归属省份地区:(.*)<\/li>/isU', $html, $matchCity);
preg_match('/<li>电信运营商:(.*)<\/li>/isU', $html, $matchIsp);
if (empty($matchCity)) {
echo "次数:{$i}/{$count} {$item} 查无数据" . PHP_EOL;
sleep(10);
continue;
}
echo "次数:{$i}/{$count} {$item} OK" . PHP_EOL;
//城市
$temp = explode('、', $matchCity[1]);
preg_match($reg1, $temp[0], $mCity);
$city = $mCity[1];
if ($temp[1]) {
preg_match($reg1, $temp[1], $mProvince);
$province = $mProvince[1];
} else {
$province = $city;
}
if (!in_array($province, $provinces)) {
list($city, $province) = array($province, $city);
}
// 运营商
preg_match($reg1, $matchIsp[1], $mIsp);
$isp = $mIsp[1];
echo "($url, $province, $city, $isp)" . PHP_EOL;
if ($i !== $count) {
sleep(10);
}
}
echo "OK";
}