{"id":151343,"date":"2024-11-01T17:21:20","date_gmt":"2024-11-01T09:21:20","guid":{"rendered":"https:\/\/server.hk\/cnblog\/151343\/"},"modified":"2024-11-01T17:21:21","modified_gmt":"2024-11-01T09:21:21","slug":"%e7%99%be%e5%ba%a6%e5%9c%b0%e5%9c%96%e7%9a%84poi%e6%95%b8%e6%93%9a%e5%ba%ab%e7%8d%b2%e5%8f%96%e6%96%b9%e6%b3%95-%e5%a6%82%e4%bd%95%e5%be%9e%e7%99%be%e5%ba%a6%e5%9c%b0%e5%9c%96%e7%8d%b2%e5%be%97poi","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/151343\/","title":{"rendered":"\u767e\u5ea6\u5730\u5716\u7684poi\u6578\u64da\u5eab\u7372\u53d6\u65b9\u6cd5 (\u5982\u4f55\u5f9e\u767e\u5ea6\u5730\u5716\u7372\u5f97poi\u6578\u64da\u5eab)"},"content":{"rendered":"<h1 id=\"%e7%99%be%e5%ba%a6%e5%9c%b0%e5%9c%96%e7%9a%84poi%e6%95%b8%e6%93%9a%e5%ba%ab%e7%8d%b2%e5%8f%96%e6%96%b9%e6%b3%95-cBVDmyDMjj\">\u767e\u5ea6\u5730\u5716\u7684POI\u6578\u64da\u5eab\u7372\u53d6\u65b9\u6cd5<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u5b57\u5316\u7684\u6642\u4ee3\uff0c\u5730\u7406\u4fe1\u606f\u7cfb\u7d71\uff08GIS\uff09\u548c\u4f4d\u7f6e\u6578\u64da\u7684\u61c9\u7528\u8d8a\u4f86\u8d8a\u5ee3\u6cdb\u3002\u767e\u5ea6\u5730\u5716\u4f5c\u70ba\u4e2d\u570b\u6700\u53d7\u6b61\u8fce\u7684\u5730\u5716\u670d\u52d9\u4e4b\u4e00\uff0c\u63d0\u4f9b\u4e86\u8c50\u5bcc\u7684POI\uff08Point of Interest\uff0c\u8208\u8da3\u9ede\uff09\u6578\u64da\u5eab\uff0c\u9019\u4e9b\u6578\u64da\u5c0d\u65bc\u958b\u767c\u8005\u3001\u5546\u696d\u5206\u6790\u5e2b\u548c\u7814\u7a76\u4eba\u54e1\u4f86\u8aaa\u90fd\u5177\u6709\u91cd\u8981\u7684\u50f9\u503c\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u5f9e\u767e\u5ea6\u5730\u5716\u7372\u53d6POI\u6578\u64da\u5eab\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u65b9\u6cd5\u548c\u793a\u4f8b\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afpoi%e6%95%b8%e6%93%9a%ef%bc%9f-cBVDmyDMjj\">\u4ec0\u9ebc\u662fPOI\u6578\u64da\uff1f<\/h2>\n<p>POI\u6578\u64da\u662f\u6307\u5730\u5716\u4e0a\u6a19\u8a18\u7684\u7279\u5b9a\u4f4d\u7f6e\uff0c\u9019\u4e9b\u4f4d\u7f6e\u901a\u5e38\u5305\u62ec\u9910\u5ef3\u3001\u5546\u5e97\u3001\u666f\u9ede\u3001\u91ab\u9662\u7b49\u3002\u9019\u4e9b\u6578\u64da\u4e0d\u50c5\u5305\u542b\u5730\u7406\u5750\u6a19\uff08\u7d93\u5ea6\u548c\u7def\u5ea6\uff09\uff0c\u9084\u5305\u62ec\u540d\u7a31\u3001\u985e\u5225\u3001\u5730\u5740\u3001\u96fb\u8a71\u865f\u78bc\u7b49\u4fe1\u606f\u3002\u9019\u4e9b\u4fe1\u606f\u5c0d\u65bc\u7528\u6236\u5c0b\u627e\u7279\u5b9a\u4f4d\u7f6e\u6216\u9032\u884c\u5546\u696d\u5206\u6790\u90fd\u975e\u5e38\u6709\u7528\u3002<\/p>\n<h2 id=\"%e7%8d%b2%e5%8f%96%e7%99%be%e5%ba%a6%e5%9c%b0%e5%9c%96poi%e6%95%b8%e6%93%9a%e7%9a%84%e6%96%b9%e6%b3%95-cBVDmyDMjj\">\u7372\u53d6\u767e\u5ea6\u5730\u5716POI\u6578\u64da\u7684\u65b9\u6cd5<\/h2>\n<h3 id=\"1-%e4%bd%bf%e7%94%a8%e7%99%be%e5%ba%a6%e5%9c%b0%e5%9c%96api-cBVDmyDMjj\">1. \u4f7f\u7528\u767e\u5ea6\u5730\u5716API<\/h3>\n<p>\u767e\u5ea6\u5730\u5716\u63d0\u4f9b\u4e86\u591a\u7a2eAPI\u63a5\u53e3\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u901a\u904e\u9019\u4e9b\u63a5\u53e3\u7372\u53d6POI\u6578\u64da\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528\u767e\u5ea6\u5730\u5716API\u7372\u53d6POI\u6578\u64da\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<ul>\n<li><strong>\u8a3b\u518a\u767e\u5ea6\u958b\u767c\u8005\u8cec\u865f\uff1a<\/strong>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u767e\u5ea6\u958b\u767c\u8005\u5e73\u53f0\u8a3b\u518a\u4e00\u500b\u8cec\u865f\uff0c\u4e26\u5275\u5efa\u4e00\u500b\u61c9\u7528\u4ee5\u7372\u53d6API\u5bc6\u9470\u3002<\/li>\n<li><strong>\u8abf\u7528POI\u67e5\u8a62\u63a5\u53e3\uff1a<\/strong>\u4f7f\u7528API\u5bc6\u9470\u8abf\u7528POI\u67e5\u8a62\u63a5\u53e3\uff0c\u60a8\u53ef\u4ee5\u6839\u64da\u95dc\u9375\u5b57\u3001\u985e\u5225\u6216\u5730\u7406\u7bc4\u570d\u4f86\u7372\u53d6POI\u6578\u64da\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\uff0c\u5c55\u793a\u5982\u4f55\u4f7f\u7528JavaScript\u8abf\u7528\u767e\u5ea6\u5730\u5716\u7684POI\u67e5\u8a62\u63a5\u53e3\uff1a<\/p>\n<pre><code>\nfunction getPOIData(keyword, location) {\n    var ak = 'YOUR_API_KEY'; \/\/ \u66ff\u63db\u70ba\u60a8\u7684API\u5bc6\u9470\n    var url = 'http:\/\/api.map.baidu.com\/place\/v2\/search?query=' + keyword + '&amp;location=' + location + '&amp;output=json&amp;ak=' + ak;\n\n    fetch(url)\n        .then(response =&gt; response.json())\n        .then(data =&gt; {\n            console.log(data);\n        })\n        .catch(error =&gt; console.error('Error:', error));\n}\n\n\/\/ \u4f7f\u7528\u793a\u4f8b\ngetPOIData('\u9910\u5ef3', '39.915,116.404'); \/\/ \u5317\u4eac\u5929\u5b89\u9580\u7684\u7d93\u7def\u5ea6\n<\/code><\/pre>\n<h3 id=\"2-%e7%b6%b2%e9%a0%81%e7%88%ac%e8%9f%b2%e6%8a%80%e8%a1%93-cBVDmyDMjj\">2. \u7db2\u9801\u722c\u87f2\u6280\u8853<\/h3>\n<p>\u5982\u679c\u60a8\u9700\u8981\u5927\u91cf\u7684POI\u6578\u64da\uff0c\u4f7f\u7528API\u53ef\u80fd\u6703\u53d7\u5230\u8abf\u7528\u6b21\u6578\u7684\u9650\u5236\u3002\u5728\u9019\u7a2e\u60c5\u6cc1\u4e0b\uff0c\u60a8\u53ef\u4ee5\u8003\u616e\u4f7f\u7528\u7db2\u9801\u722c\u87f2\u6280\u8853\u4f86\u6293\u53d6\u767e\u5ea6\u5730\u5716\u4e0a\u7684POI\u6578\u64da\u3002\u9019\u7a2e\u65b9\u6cd5\u9700\u8981\u4e00\u5b9a\u7684\u7de8\u7a0b\u77e5\u8b58\uff0c\u4e26\u4e14\u9700\u8981\u9075\u5faa\u7db2\u7ad9\u7684\u4f7f\u7528\u689d\u6b3e\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528Python\u7684BeautifulSoup\u5eab\u9032\u884c\u7db2\u9801\u722c\u87f2\u7684\u7c21\u55ae\u793a\u4f8b\uff1a<\/p>\n<pre><code>\nimport requests\nfrom bs4 import BeautifulSoup\n\ndef scrape_poi_data(url):\n    response = requests.get(url)\n    soup = BeautifulSoup(response.text, 'html.parser')\n    \n    pois = soup.find_all('div', class_='poi-item')  # \u5047\u8a2dPOI\u9805\u76ee\u5728\u9019\u500bclass\u4e2d\n    for poi in pois:\n        name = poi.find('h3').text\n        address = poi.find('p', class_='address').text\n        print(f'\u540d\u7a31: {name}, \u5730\u5740: {address}')\n\n# \u4f7f\u7528\u793a\u4f8b\nscrape_poi_data('https:\/\/map.baidu.com\/search\/?query=\u9910\u5ef3')\n<\/code><\/pre>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-cBVDmyDMjj\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u7372\u53d6POI\u6578\u64da\u6642\uff0c\u8acb\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u9075\u5faa\u767e\u5ea6\u7684API\u4f7f\u7528\u689d\u6b3e\uff0c\u907f\u514d\u904e\u5ea6\u8abf\u7528API\u3002<\/li>\n<li>\u4f7f\u7528\u7db2\u9801\u722c\u87f2\u6642\uff0c\u8acb\u9075\u5faarobots.txt\u6587\u4ef6\u4e2d\u7684\u898f\u5b9a\uff0c\u4e26\u5c0a\u91cd\u7db2\u7ad9\u7684\u4f7f\u7528\u689d\u6b3e\u3002<\/li>\n<li>\u78ba\u4fdd\u6578\u64da\u7684\u6e96\u78ba\u6027\u548c\u53ca\u6642\u6027\uff0c\u5b9a\u671f\u66f4\u65b0\u60a8\u7684\u6578\u64da\u5eab\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-cBVDmyDMjj\">\u7e3d\u7d50<\/h2>\n<p>\u7372\u53d6\u767e\u5ea6\u5730\u5716\u7684POI\u6578\u64da\u5eab\u53ef\u4ee5\u901a\u904eAPI\u8abf\u7528\u6216\u7db2\u9801\u722c\u87f2\u6280\u8853\u4f86\u5be6\u73fe\u3002\u9019\u4e9b\u6578\u64da\u5c0d\u65bc\u5404\u7a2e\u61c9\u7528\u5834\u666f\u90fd\u5177\u6709\u91cd\u8981\u7684\u50f9\u503c\u3002\u7121\u8ad6\u60a8\u662f\u958b\u767c\u8005\u9084\u662f\u5546\u696d\u5206\u6790\u5e2b\uff0c\u638c\u63e1\u9019\u4e9b\u6280\u8853\u90fd\u80fd\u5e6b\u52a9\u60a8\u66f4\u597d\u5730\u5229\u7528\u5730\u7406\u6578\u64da\u3002\u82e5\u60a8\u9700\u8981\u7a69\u5b9a\u7684\u670d\u52d9\u5668\u4f86\u652f\u6301\u60a8\u7684\u61c9\u7528\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u4e91\u670d\u52d9\u5668<\/a>\uff0c\u4ee5\u78ba\u4fdd\u60a8\u7684\u6578\u64da\u8655\u7406\u548c\u5b58\u5132\u9700\u6c42\u5f97\u5230\u6eff\u8db3\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5f9e\u767e\u5ea6\u5730\u5716\u7372\u53d6POI\u6578\u64da\u5eab\uff0c\u638c\u63e1\u6709\u6548\u7684\u65b9\u6cd5\u548c\u6280\u5de7\uff0c\u8f15\u9b06\u7372\u53d6\u6240\u9700\u7684\u5730\u7406\u4fe1\u606f\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-151343","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/151343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=151343"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/151343\/revisions"}],"predecessor-version":[{"id":151344,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/151343\/revisions\/151344"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=151343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=151343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=151343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}