Blogger Information
Blog 15
fans 0
comment 0
visits 27823
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
汽车型号json数据(汽车之家)
陈序员的博客
Original
1824 people have browsed it

AUTOHOME的 

http://www.autohome.com.cn/ashx/AjaxIndexCarFind.ashx?type=1

或者

http://www.autohome.com.cn/ashx/AjaxIndexCarFind.ashx?type=11

获取***列表,然后

http://www.autohome.com.cn//ashx/AjaxIndexCarFind.ashx?type=3&value=3

获取车型列表(例子中的value=3对应丰田)。

生成json代码:

public function setCarJson()	{
    		ini_set('max_execution_time', '0');
    		$carJson = array();				
    		$list = file_get_contents('https://www.autohome.com.cn/ashx/AjaxIndexCarFind.ashx?type=1');				
    		$list = json_decode(iconv("GBK", "UTF-8//IGNORE", $list),true);				
    		if($list['message'] == '成功'){						
    		    $pingpai = $list['result']['branditems'];						
    		    foreach($pingpai as $k=>$v){								
    		    //判断数组中是否包含A,B键				
    		    if(!isset($carJson[$v['bfirstletter']])){
    		    	$carJson[$v['bfirstletter']] = [];				
    		    }								
    		    $newArr = ['city'=>['name'=>$v['name'],'code'=>$v['id'],'areaList'=>[]]];								
    		    $url = 'https://www.autohome.com.cn//ashx/AjaxIndexCarFind.ashx?type=3&value='.$v['id'];								
    		    $list1 = file_get_contents($url);								
    		    $list1 = json_decode(iconv("GBK", "UTF-8//IGNORE", $list1),true);								
    		    if($list1['message'] == '成功' && isset($list1['result']['factoryitems'][0]['seriesitems'])){										
    		        $chexing = $list1['result']['factoryitems'][0]['seriesitems'];									
    		        foreach($chexing as $kk=>$vv){						
    		            array_push($newArr['city']['areaList'],['name'=>$vv['name'],'code'=>$vv['id']]);					
    		        }									}								
    		        array_push($carJson[$v['bfirstletter']], $newArr);								
    		        unset($newArr);							
    		     }					
    		 }				
    		 dump(json_encode($carJson,JSON_UNESCAPED_UNICODE));		
    		 // dump($newArr);	
}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
1 comments
a梅梅 2020-11-18 14:50:30
$list = file_get_contents('https://www.autohome.com.cn/ashx/AjaxIndexCarFind.ashx?type=1'); $list = json_decode(iconv("GBK", "UTF-8//IGNORE", $list), true); 这两个获取出来都是乱码
1 floor
Author's latest blog post