API Precise Location IP address

Source: Internet
Author: User

Suddenly found that the Baidu API more and more useful, simple use of Baidu API precision positioning IP address. Python code included

Category:Python

(4778) (5)

November 27, 2016 08:13:13

API Service Address:
Http://lbsyun.baidu.com/index.php?title=webapi/high-acc-ip

How to use:
The first step, the application of the key (AK), as the basis for accessing the service;
The second step, the spelling sends the URL of the HTTP/HTTPS request, note the AK that needs to use the first step of the application;
The third step is to receive the data returned by the HTTP/HTTPS request (JSON/JSONP format)

Service Address:
Http://api.map.baidu.com/highacciploc/v1
Https://api.map.baidu.com/highacciploc/v1

Note: When applying for developer certification, the use of 163 mailbox authentication failed, do not know why (November 27, 2016 08:23:32)

Test Address:
http://api.map.baidu.com/highacciploc/v1?qcip=139.214.254.47&qterm=pc&ak= Naw5vg6u5teluz2stdslqpsyirkoiofz&coord=bd09ll&extensions=3

Feedback results:
{"Content": {"location": {"lat": 43.862307, "LNG": 125.332422}, "Locid": "fb823867162b178b3e180993e4638d41", "radius" : 2060684, "confidence": 0.2, "address_component": {"Country": "China", "province": "Jilin Province", "City": "Changchun", "District": "Nanguan District", " Street ":" People's Main Street "," Street_number ":" No. No. 5766 "," Admin_area_code ": 220102}," formatted_address ":" No. 5766 Renmin Street, Changchun Nanguan District, Jilin Province "," Business ":" Renmin Street, Nanling, Nanhu Park "}," result ": {" error ": 161," Loc_time ":" 2016-11-27 08:36:41 "}}


[Python]View PlainCopy
  1. #-*-Coding:utf-8-*-
  2. Import requests
  3. Import JSON
  4. s = requests.session ()
  5. url = ' http://api.map.baidu.com/highacciploc/v1?qcip=139.214.254.47&qterm=pc&ak=YourKey&coord= Bd09ll&extensions=3 '
  6. Header = {' user-agent ':' mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) gecko/20100101 firefox/50.0 '}
  7. Response = S.get (URL, headers = header, timeout = )
  8. Print (Response.text)
  9. JSON = Json.loads (response.text)
  10. Print (' Location: ' +str (json[' content ' [' formatted_address ']))
  11. Print (' Business Circle: ' +str (json[' content ' [' Business ']))
  12. Print (' Longitude: ' +str (json[' content ' [' location '] [' lat ']))
  13. Print (' Dimension: ' +str (json[' content ' [' location '] [' LNG '] )
  14. Print (' accuracy: ' +str (json[' content ' [' confidence ']))
  15. #练习时间: November 27, 2016 10:54:36
  16. #1, note the use of character encoding.
  17. #2, note Modify the user-agent in the requests request header.
  18. The data returned by #3, JSON may be int or float, etc., and note character conversions when printing.
  19. #4, replace the API with the IP address you need to query and your key string.



=====================
Input results
{"Content": {"location": {"lat": 43.862307, "LNG": 125.332422}, "Locid": "180d8c65fa25fefaf6eb9ae6481e1f4c", "radius" : 2060684, "confidence": 0.2, "address_component": {"Country": "China", "province": "Jilin Province", "City": "Changchun", "District": "Nanguan District", " Street ":" People's Main Street "," Street_number ":" No. No. 5766 "," Admin_area_code ": 220102}," formatted_address ":" No. 5766 Renmin Street, Changchun Nanguan District, Jilin Province "," Business ":" Renmin Street, Nanling, Nanhu Park "}," result ": {" error ": 161," Loc_time ":" 2016-11-27 10:45:03 "}}

Location: No. No. 5766, Renmin Street, Nanguan District, Changchun, Jilin Province
Shopping district: Renmin Street, Nanling, Nanhu Park
Longitude: 43.862307
Dimension: 125.332422
Accuracy: 0.2

API Precise Location IP address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.