Files
smartParsePro/README.md

217 lines
7.4 KiB
Markdown
Raw Normal View History

2022-04-29 11:30:09 +08:00
<p align="center"><a href="http://wzhichao.gitee.io/smartparse/#/smartParse/fq" target="_blank" rel="noopener noreferrer"><img src="http://wzhichao.gitee.io/smart-doc/images/logo.png" alt="smartparse logo"></a></p>
2021-03-11 18:03:08 +08:00
2021-11-24 11:00:05 +08:00
### `star` -`1k`后开源后端代码(支持地址更加丰富),快推荐给你身边的小伙伴使用吧
2021-03-11 18:03:08 +08:00
<p align="center">
<a href="https://www.npmjs.com/package/address-smart-parse"><img src="https://img.shields.io/npm/v/address-smart-parse.svg?sanitize=true" alt="Version"></a>
2021-03-11 18:05:31 +08:00
<a href="https://github.com/wzc570738205/smartParsePro"><img src="https://img.shields.io/github/stars/wzc570738205/smartParsePro?style=social" alt="stars"></a>
2021-03-11 18:07:51 +08:00
<a href="https://github.com/wzc570738205/smartParsePro"><img alt="GitHub forks" src="https://img.shields.io/github/forks/wzc570738205/smartParsePro?label=Fork&style=social"></a>
2021-03-11 18:03:08 +08:00
</p>
2019-09-12 13:44:29 +08:00
2021-06-21 09:45:02 +08:00
# 智能识别收货地址Pro支持省市区县街道/姓名/电话/邮编识别)
2022-03-25 09:56:28 +08:00
### 文档地址:[doc](http://wzhichao.gitee.io/smart-doc/) | [备用(gitee)](http://wzhichao.gitee.io/smartParse) | [备用(语雀)](https://www.yuque.com/books/share/72418abc-287d-4a67-ae3c-dad10928c631?#)
2019-10-14 16:09:56 +08:00
2022-03-25 09:56:28 +08:00
### 在线预览: [示例一](https://wangzc.wang/smartParsePro/) [备用地址](http://wzhichao.gitee.io/smartparsepro/)
2021-09-22 15:55:57 +08:00
2020-01-02 10:21:45 +08:00
![image.png](https://s2.ax1x.com/2020/01/02/lYkqdx.png)
2019-09-12 13:44:29 +08:00
## 地址数据来源(数据不对请更新此json)
2020-06-11 17:15:41 +08:00
2019-09-12 15:43:01 +08:00
更新方法将此json文件内容复制至同名js里的var pcassCode=xxxx;
2019-09-12 15:43:28 +08:00
2020-03-12 15:56:47 +08:00
[pcas-code.json(点击前往)](https://github.com/modood/Administrative-divisions-of-China/blob/master/dist/pcas-code.json)
2019-09-12 13:44:29 +08:00
2020-06-11 17:15:41 +08:00
## 港澳台地址
2020-06-11 17:16:10 +08:00
参考[港澳台](https://github.com/modood/Administrative-divisions-of-China/issues/27) 可进行自整理
2020-06-11 17:15:41 +08:00
2020-05-13 09:10:08 +08:00
## 支持以下数据格式
2021-06-22 09:22:49 +08:00
### 注意:地址、姓名、电话、邮编用空格或者特殊字符分开
2020-05-13 09:10:08 +08:00
2019-09-12 18:02:23 +08:00
特殊字符(可自行添加)
```
~!@#$^&*()=|{}':;',\\[\\].<>/?~@#¥……&*()——|{}【】‘;:”“’。,、?-
```
2020-11-16 19:09:49 +08:00
### js支持地址格式
2022-02-21 11:35:50 +08:00
```
1. 广东省珠海市香洲区盘山路28号幸福茶庄,陈景勇13593464918
2019-09-12 18:05:05 +08:00
2. 马云,陕西省西安市雁塔区丈八沟街道高新四路高新大都荟 13593464918
2020-12-01 16:49:52 +08:00
3. 陕西省西安市雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918
4. 西安市雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918
5. 雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918
2022-02-21 11:35:50 +08:00
```
2020-11-16 19:09:49 +08:00
### 接口额外支持关键字多种地址格式
2022-02-21 11:35:50 +08:00
```
2020-11-16 19:09:49 +08:00
6. 收货人: 李节霁
手机号码: 15180231234
所在地区: 浙江省金华市婺城区西关街道
详细地址: 金磐路上坞街
7. 收货人: 马云
手机号码: 150-3569-6956
详细地址: 河北省石家庄市新华区中华北大街68号鹿城商务中心6号楼1413室
2022-02-21 11:35:50 +08:00
```
2020-05-13 09:10:08 +08:00
## 使用方法
2021-10-08 10:50:09 +08:00
### 1.api调用
2022-05-05 17:32:25 +08:00
>部署腾讯云单IP调用3条/s限制需要自行部署请[点击](http://wzhichao.gitee.io/smartparse/#/smartParse/fq)
2021-10-28 17:28:56 +08:00
2022-03-25 09:56:28 +08:00
```js
2020-05-22 10:15:45 +08:00
request urlhttps://wangzc.wang/smAddress
2020-05-15 10:24:05 +08:00
request methods: POST
2020-05-13 00:09:40 +08:00
2020-05-15 10:24:05 +08:00
request payload:
2020-05-15 10:20:55 +08:00
2020-05-13 00:09:40 +08:00
{
2020-06-01 14:12:24 +08:00
"address": "新疆阿克苏温宿县博孜墩柯尔克孜族乡吾斯塘博村一组306号 150-3569-6956 马云",
"addressList": [
"新疆阿克苏温宿县博孜墩柯尔克孜族乡吾斯塘博村一组306号 150-3569-6956 马云",
"雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918 211381198512096810"
]
2020-05-13 00:09:40 +08:00
}
2020-06-01 14:12:24 +08:00
//address 字段为单条识别
//addressList 字段为集合识别 返回在response的list字段中
2020-05-15 10:24:05 +08:00
response
2020-05-15 10:20:55 +08:00
2020-05-13 00:09:40 +08:00
{
2020-06-01 14:12:24 +08:00
"province": "新疆维吾尔自治区",
"provinceCode": "65",
"city": "阿克苏地区",
"cityCode": "6529",
"county": "温宿县",
"countyCode": "652922",
"street": "博孜墩柯尔克孜族乡",
"streetCode": "652922207",
"address": "吾斯塘博村一组306号",
"phone": "15035696956",
"name": "马云",
"requestNumber": 7,
"list": [
{
"province": "新疆维吾尔自治区",
"provinceCode": "65",
"city": "阿克苏地区",
"cityCode": "6529",
"county": "温宿县",
"countyCode": "652922",
"street": "博孜墩柯尔克孜族乡",
"streetCode": "652922207",
"address": "吾斯塘博村一组306号",
"phone": "15035696956",
"name": "马云"
},
{
"zipCode": "710061",
"county": "雁塔区",
"countyCode": "610113",
"province": "陕西省",
"provinceCode": "61",
"city": "西安市",
"cityCode": "6101",
"street": "丈八沟街道",
"streetCode": "610113007",
"address": "高新四路高新大都荟",
"name": "刘国良",
"phone": "13593464918",
"idCard": "211381198512096810"
}
]
2020-05-13 00:09:40 +08:00
}
2020-05-15 10:20:55 +08:00
2020-05-13 00:09:40 +08:00
```
2020-05-13 09:10:08 +08:00
api使用推荐axios
2022-03-25 09:56:28 +08:00
```js
2020-05-15 10:20:55 +08:00
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
axios({
method: "post",
2020-05-22 10:17:00 +08:00
url: "https://wangzc.wang/smAddress",
2020-05-15 10:20:55 +08:00
data: {
address: '广东省珠海市香洲区盘山路28号幸福茶庄,陈景勇13593464918',
},
}).then(function (res) {});
2020-05-13 09:10:08 +08:00
```
2020-08-12 09:00:44 +08:00
### 2.NPM
2022-03-25 09:56:28 +08:00
```sh
2020-08-11 16:34:14 +08:00
npm install address-smart-parse
```
2022-03-25 09:56:28 +08:00
```js
2020-08-11 16:34:14 +08:00
import smart from 'address-smart-parse'
2020-05-13 16:14:32 +08:00
2020-08-11 16:34:14 +08:00
// console.log(smart('xxxxxxx))
```
2022-03-25 09:56:28 +08:00
### 3.script引入
2020-07-01 14:24:17 +08:00
[在codepen中在线预览](https://codepen.io/wzc570738205/pen/RwrjLbq)
2019-09-12 15:39:50 +08:00
```
2020-04-15 11:26:54 +08:00
<script src="js/pcasCode.js"></script>
<script src="js/zipCode.js"></script>
<script src="js/address_parse.js"></script>
2022-03-25 09:56:28 +08:00
2022-02-21 11:37:25 +08:00
//jsdelivr
<script src="https://cdn.jsdelivr.net/npm/address-smart-parse@1.0.0/pcasCode.js"></script>
<script src="https://cdn.jsdelivr.net/npm/address-smart-parse@1.0.0/zipCode.js"></script>
<script src="https://cdn.jsdelivr.net/npm/address-smart-parse@1.0.0/address_parse.js"></script>
2020-04-15 11:26:54 +08:00
2019-09-16 11:41:59 +08:00
smart("陕西省西安市雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918 211381198512096810")
2019-09-12 15:39:50 +08:00
```
2019-10-14 16:09:56 +08:00
2022-03-25 09:56:28 +08:00
### 4.Python调用
```
import requests
URL='https://wangzc.wang/smAddress'
data=lambda x : r'{"address":"' + x + '"}'
address=r'陕西省西安市雁塔区丈八沟街道高新四路高新大都荟710061 刘国良 13593464918 211381198512096810' # address
requests.post(url=URL,data=data(address).encode('utf-8'))
print(res.json()) # output
```
2019-10-14 16:09:56 +08:00
2019-09-12 13:44:29 +08:00
## 生成数据格式
2022-02-21 11:37:25 +08:00
```json
2019-09-12 13:44:29 +08:00
{
2022-02-21 11:39:55 +08:00
"zipCode":"710061",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"province":"陕西省",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"provinceCode":"61",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"city":"西安市",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"cityCode":"6101",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"county":"雁塔区",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"countyCode":"610113",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"street":"丈八沟街道",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"streetCode":"610113007",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"address":"高新四路高新大都荟",
2019-09-12 13:44:29 +08:00
2022-02-21 11:39:55 +08:00
"name":"刘国良",
2019-09-16 11:41:59 +08:00
2022-02-21 11:39:55 +08:00
"phone":"13593464918",
2019-09-16 11:41:59 +08:00
2022-02-21 11:39:55 +08:00
"idCard":"211381198512096810"
2019-09-12 13:44:29 +08:00
}
```
2020-05-13 09:26:52 +08:00
2019-09-12 13:44:29 +08:00
##### 地址数据来源:[中华人民共和国行政区划](https://github.com/modood/Administrative-divisions-of-China)
2019-09-12 16:52:30 +08:00
##### 邮编数据来源:[中华人民共和国邮编](https://github.com/xieranmaya/china-city-area-zip-data/blob/master/china-city-area-zip.json)
2020-06-09 10:10:36 +08:00
#### LICENSE[Apache License](https://github.com/wzc570738205/smartParsePro/blob/master/LICENSE)
2021-06-21 09:31:24 +08:00
#### IDE:致谢[JetBrains](https://www.jetbrains.com/?from=smartParsePro)为本项目提供免费license支持
2020-08-20 09:23:12 +08:00
[![JetBrains](http://cdn.wangzc.wang/LOGO-1.png)](https://www.jetbrains.com/?from=smartParsePro)
2020-05-13 09:26:52 +08:00
#### 请作者喝杯咖啡☕️
2020-05-21 11:47:07 +08:00
![](http://cdn.wangzc.wang/uPic/cDQzFD.jpg)
2021-10-08 10:50:09 +08:00
#### 公众号
![qrcode](https://user-images.githubusercontent.com/21350874/136490435-cb0eefc8-31cc-4451-ba25-ede2dacbc55e.png)
#### 交流群
2022-03-30 17:17:05 +08:00
![WX20210922-091703.png](https://cdn.wangzc.wang/uPic/WX20210922-09170315%20.png)
2020-05-13 09:26:52 +08:00