Giter Club home page Giter Club logo

laravel-province-city-area's Introduction

Laravel-Province-City-Area 全国省市县数据(数据来源于京东,内置爬虫,可自行获取最新数据)

这是一个提供全国省市县数据的轮子

试过了很多数据来源(国家统计局、网上其他开发者提供的json等),发现还是会有小部分省市有遗漏。

这个包的数据是来自于京东,相对来说会更准确、详尽一些。

内部自带京东省市县数据爬虫,用户可以自行运行爬取最新的省市县数据

添加provider(laravel 版本 < 5.5)

Aoxiang\Pca\ProvinceCityAreaServiceProvider::class复制到config.phpproviders数组内

生成数据库迁移文件:

php artisan vendor:publish --provider="Aoxiang\Pca\ProvinceCityAreaServiceProvider" --tag="migrations"

执行数据库迁移

php artisan migrate

最后一步:从京东获取新的省市县数据

php artisan pca:refreshData
获取数据成功:**阿勒泰地区
获取数据成功:**五家渠市
获取数据成功:**阿拉尔市
获取数据成功:**图木舒克市
获取数据成功:**铁门关市
获取数据成功:**昆玉市
获取数据成功:****
获取数据成功:钓鱼岛钓鱼岛
获取数据成功:港澳香港特别行政区
获取数据成功:港澳澳门特别行政区
正在插入数据库
 5252/5662 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░]  92%

执行完成就可以用了

Demo

<?php

namespace App\Http\Controllers;

use Aoxiang\Pca\ProvinceCityArea;
use Illuminate\Routing\Controller as BaseController;

class Controller  extends BaseController{
    public function getProvinceList()
    {
        return response()->json(ProvinceCityArea::getProvinceList());
    }
    
    public function getCityList()
    {
        ProvinceCityArea::getCityList(1);
    }
    
    public function test()
    {
        echo ProvinceCityArea::getName(21, 1827, 40847);
        //echo "江西南昌市红谷滩新区";
    }
}

laravel-province-city-area's People

Contributors

aoxiang594 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.