<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                #### 百度地圖獲取-全國數據(名稱,地址,電話) 通過調用百度地圖,抓取全國某個地方的數據,如餐廳,車管所 #### 1.在百度地圖開放api上注冊一個帳號 并創建應用,獲取一個調用密鑰,一般密鑰每天都有調用限制,有時需要好幾天才能處理完一份數據 具體參考: http://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-placeapi #### 2.需要自己有全國城市的數據,獲取到百度地圖去獲取 接下來,在我的城市表里增加兩個字段,isdeal:表示該城市是否處理完,dealpage:表示當前城市獲取到第幾頁,默認從0開始,然后不斷遍歷城市獲取數據,當處理完成或者處理不了把isdeal=1,處理完一頁之后,dealpage+1. Php案例代碼: ~~~ /** * 爬蟲 -》車管所 -》交警大隊 */ public function curl() { /** * 1.先獲取城市 */ $cityService = service('City'); $officeService = service('BtrOffice'); //獲取一個未處理城市 $city = $cityService->where(['isdeal' => 0])->order('id asc')->find(); if (!$city) { return success("數據已經處理完成!"); } $parameter = [ 'query' => '車管所',//要查詢的地方,如餐廳 'page_size' => 20,//每頁大小,最多20 'page_num' => $city['dealpage'], 'scope' => 1,//1 或空,則返回基本信息 'region' => $city['name'],//城市名稱或百度地圖城市代碼 'output' => 'json',//返回格式 'ak'=>'c6hlXlNBKnVYMQVEIeX0MW7BRGPcGU17'//應用密鑰,有限制 // 'ak' => '4oyItR1wqUfit5q4lGNO3kd5roGmmccy' ]; $url = 'http://api.map.baidu.com/place/v2/search?' . http_build_query($parameter);//拼接參數 $result = json_decode(http_request($url), true); if ($result['status'] != 0) {//返回錯誤結果 return error($result['message']); } if (isset($result['results'])) { $content = $result['results']; if (count($content) <= 0) {//過濾數據 $city['isdeal'] = 1; $res = $cityService->update($city); if ($res) { log_debug("獲取車管所", $city['name'] . '處理完成'); return success("{$city['name']}-城市處理完成"); } else { log_debug("獲取車管所", $city['name'] . '處理完成異常'); return error("{$city['name']}處理完成異常"); } } /** * 保存數據 */ foreach ($content as $item) { //省份數據 //數據有設置 if (isset($item['num'])&&$item['num']>=0) {//過濾數據 $city['isdeal'] = 1; $res = $cityService->update($city); if ($res) { log_debug("獲取車管所", $city['name'] . '處理完成'); return success("{$city['name']}-城市處理完成"); } else { log_debug("獲取車管所", $city['name'] . '處理完成異常'); return error("{$city['name']}處理完成異常"); } } //保存數據進庫 $office['type'] = 1;//車管所 $office['city_id'] = $city['id']; if (isset($item['name'])) $office['name'] = $item['name']; else { continue; } if (isset($item['telephone'])) $office['phone'] = $item['telephone']; //組裝地址 if (isset($item['address'])) $office['address'] = $item['address']; if (isset($item['location']['lat'])) $office['lat'] = $item['location']['lat']; if (isset($item['location']['lng'])) $office['lng'] = $item['location']['lng']; $res = $officeService->add($office); if (!$res) { log_debug("車管所數據", "添加失敗"); } } //處理下一頁 $city['dealpage'] = $city['dealpage'] + 1; $res = $cityService->update($city); if (!$res) { log_debug("車管所數據", "處理下一頁失敗"); return error($city['name'] . ":處理一頁失敗"); } else { return success($city['name'] . ":處理一頁"); } } else { $city['isdeal'] = 1; $res = $cityService->update($city); if ($res) { log_debug("獲取車管所", $city['name'] . '處理完成'); return success("{$city['name']}-城市處理完成"); } else { log_debug("獲取車管所", $city['name'] . '處理完成異常'); return error("{$city['name']}處理完成異常"); } } } ~~~ 結果預覽: ![](https://box.kancloud.cn/668912898856b8fae501344822e52d6b_906x599.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看