{"id":1401,"date":"2026-07-07T19:11:47","date_gmt":"2026-07-07T11:11:47","guid":{"rendered":"https:\/\/www.loongdi.net\/blog\/?p=1401"},"modified":"2026-07-07T19:11:47","modified_gmt":"2026-07-07T11:11:47","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e7%99%be%e5%ba%a6%e6%96%b0%e9%97%bb%e6%ba%90%e5%ae%9e%e6%97%b6%e8%8e%b7%e5%8f%96%e6%96%b0%e9%97%bb%e6%95%b0%e6%8d%ae%e4%bb%a5%e5%8f%8a%e5%be%b7%e8%ae%af%e7%94%b5","status":"publish","type":"post","link":"https:\/\/www.loongdi.net\/blog\/1401.html","title":{"rendered":"\u5982\u4f55\u5229\u7528\u767e\u5ea6\u65b0\u95fb\u6e90\u5b9e\u65f6\u83b7\u53d6\u65b0\u95fb\u6570\u636e\u4ee5\u53ca\u5fb7\u8baf\u7535\u8baf\u63a8\u8350\u3010\u63a8\u8350\u3011"},"content":{"rendered":"<p><p>\u767e\u5ea6\u65b0\u95fb\u6e90\u662f\u767e\u5ea6\u65b0\u95fb\u641c\u7d22\u7684\u4e00\u4e2a\u6570\u636e\u63a5\u53e3\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u83b7\u53d6\u767e\u5ea6\u65b0\u95fb\u7684\u5b9e\u65f6\u6570\u636e\u3002\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06\u60a8\u7684\u7f51\u7ad9\u6216\u5e94\u7528\u63a5\u5165\u767e\u5ea6\u65b0\u95fb\u6e90\uff0c\u5b9e\u73b0\u65b0\u95fb\u6570\u636e\u7684\u5b9e\u65f6\u83b7\u53d6\u3002<\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u524d\u7684\u51c6\u5907<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u64cd\u4f5c\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u6ce8\u518c\u4e86\u767e\u5ea6\u65b0\u95fb\u6e90\u8d26\u53f7\u3002<\/li>\n<li>\u83b7\u53d6\u4e86API\u5bc6\u94a5\u3002<\/li>\n<li>\u4e86\u89e3\u4e86\u81ea\u5df1\u7684\u7f51\u7ad9\u6216\u5e94\u7528\u7684\u4e1a\u52a1\u9700\u6c42\u3002<\/li>\n<\/ul>\n<p><h2>\u4efb\u52a1\uff1a\u63a5\u5165\u767e\u5ea6\u65b0\u95fb\u6e90<\/h2>\n<\/p>\n<p><p>\u672c\u4efb\u52a1\u7684\u76ee\u6807\u662f\u8ba9\u60a8\u80fd\u591f\u4ece\u767e\u5ea6\u65b0\u95fb\u6e90\u83b7\u53d6\u65b0\u95fb\u6570\u636e\uff0c\u5e76\u5c06\u5176\u5c55\u793a\u5728\u60a8\u7684\u7f51\u7ad9\u6216\u5e94\u7528\u4e2d\u3002<\/p>\n<\/p>\n<p><h3>\u6b65\u9aa4 1\uff1a\u83b7\u53d6API\u5bc6\u94a5<\/h3>\n<\/p>\n<p><p>\u767b\u5f55\u767e\u5ea6\u65b0\u95fb\u6e90\u63a7\u5236\u53f0\uff0c\u83b7\u53d6\u60a8\u7684API\u5bc6\u94a5\u3002<\/p>\n<\/p>\n<p><h3>\u6b65\u9aa4 2\uff1a\u5b89\u88c5\u5fc5\u8981\u7684\u5e93<\/h3>\n<\/p>\n<p><p>\u5728\u60a8\u7684\u5f00\u53d1\u73af\u5883\u4e2d\u5b89\u88c5Python\u7684`requests`\u5e93\u3002<\/p>\n<\/p>\n<p><pre><code>pip install requests<\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 3\uff1a\u7f16\u5199\u8bf7\u6c42\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\uff0c\u7528\u4e8e\u83b7\u53d6\u65b0\u95fb\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code>import requests<\/p>\r\n\r\n<p>def get_news(api_key, query, start_time, end_time):<\/p>\r\n<p>    url = \"http:\/\/news.baidu.com\/n?tn=news&from=news&word={}&start_time={}&end_time={}\".format(query, start_time, end_time)<\/p>\r\n<p>    headers = {<\/p>\r\n<p>        \"Authorization\": \"Bearer {}\".format(api_key)<\/p>\r\n<p>    }<\/p>\r\n<p>    response = requests.get(url, headers=headers)<\/p>\r\n<p>    return response.json()<\/p>\r\n\r\n<p> \u4f7f\u7528\u793a\u4f8b<\/p>\r\n<p>api_key = \"YOUR_API_KEY\"<\/p>\r\n<p>query = \"\u79d1\u6280\"<\/p>\r\n<p>start_time = \"2021-01-01\"<\/p>\r\n<p>end_time = \"2021-01-02\"<\/p>\r\n<p>news_data = get_news(api_key, query, start_time, end_time)<\/p>\r\n<p>print(news_data)<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 4\uff1a\u89e3\u6790\u8fd4\u56de\u7684\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u767e\u5ea6\u65b0\u95fb\u6e90\u8fd4\u56de\u7684\u6570\u636e\u662fJSON\u683c\u5f0f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Python\u7684`json`\u5e93\u6765\u89e3\u6790\u8fd9\u4e9b\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code>import json<\/p>\r\n\r\n<p> \u5047\u8bbenews_data\u662f\u4e0a\u8ff0get_news\u51fd\u6570\u8fd4\u56de\u7684\u6570\u636e<\/p>\r\n<p>parsed_data = json.loads(news_data)<\/p>\r\n<p>print(parsed_data)<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 5\uff1a\u5c55\u793a\u65b0\u95fb\u6570\u636e<\/h3>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.loongdi.net\/blog\/wp-content\/uploads\/2026\/03\/1a83LaFi.jpg\" alt=\"\u5982\u4f55\u5229\u7528\u767e\u5ea6\u65b0\u95fb\u6e90\u5b9e\u65f6\u83b7\u53d6\u65b0\u95fb\u6570\u636e\u4ee5\u53ca\u5fb7\u8baf\u7535\u8baf\u63a8\u8350\u3010\u63a8\u8350\u3011\" title=\"\u5982\u4f55\u5229\u7528\u767e\u5ea6\u65b0\u95fb\u6e90\u5b9e\u65f6\u83b7\u53d6\u65b0\u95fb\u6570\u636e\u4ee5\u53ca\u5fb7\u8baf\u7535\u8baf\u63a8\u8350\u3010\u63a8\u8350\u3011\"><\/p>\n<p><p>\u6839\u636e\u60a8\u7684\u9700\u6c42\uff0c\u5c06\u89e3\u6790\u540e\u7684\u65b0\u95fb\u6570\u636e\u5c55\u793a\u5728\u60a8\u7684\u7f51\u7ad9\u6216\u5e94\u7528\u4e2d\u3002<\/p>\n<\/p>\n<p><h2>\u6ce8\u610f\u4e8b\u9879<\/h2>\n<\/p>\n<ul>\n<li><strong>API\u5bc6\u94a5<\/strong>\uff1a\u8bf7\u59a5\u5584\u4fdd\u7ba1\u60a8\u7684API\u5bc6\u94a5\uff0c\u4e0d\u8981\u6cc4\u9732\u7ed9\u4ed6\u4eba\u3002<\/li>\n<li><strong>\u8bf7\u6c42\u9891\u7387<\/strong>\uff1a\u9075\u5b88\u767e\u5ea6\u65b0\u95fb\u6e90\u7684\u8bf7\u6c42\u9891\u7387\u9650\u5236\uff0c\u907f\u514d\u56e0\u9891\u7e41\u8bf7\u6c42\u800c\u88ab\u5c01\u7981\u3002<\/li>\n<li><strong>\u6570\u636e\u683c\u5f0f<\/strong>\uff1a\u786e\u4fdd\u60a8\u7684\u4ee3\u7801\u80fd\u591f\u6b63\u786e\u89e3\u6790\u767e\u5ea6\u65b0\u95fb\u6e90\u8fd4\u56de\u7684JSON\u6570\u636e\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<p><h2>\u5e38\u89c1\u95ee\u9898<\/h2>\n<\/p>\n<ul>\n<li><strong>Q\uff1a<\/strong>\u5982\u4f55\u83b7\u53d6\u66f4\u591a\u7684\u65b0\u95fb\u6570\u636e\uff1f<\/p>\n<li><strong>A\uff1a<\/strong>\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u67e5\u8be2\u53c2\u6570\uff0c\u5982\u589e\u52a0\u65b0\u95fb\u7c7b\u578b\u3001\u5730\u533a\u7b49\uff0c\u6765\u83b7\u53d6\u66f4\u591a\u6837\u5316\u7684\u65b0\u95fb\u6570\u636e\u3002<\/li>\n<\/li>\n<li><strong>Q\uff1a<\/strong>\u5982\u679c\u8bf7\u6c42\u88ab\u62d2\u7edd\u600e\u4e48\u529e\uff1f<\/p>\n<li><strong>A\uff1a<\/strong>\u68c0\u67e5\u60a8\u7684API\u5bc6\u94a5\u662f\u5426\u6709\u6548\uff0c\u4ee5\u53ca\u662f\u5426\u8d85\u8fc7\u4e86\u8bf7\u6c42\u9891\u7387\u9650\u5236\u3002\u5982\u679c\u95ee\u9898\u4f9d\u65e7\uff0c\u8bf7\u8054\u7cfb\u767e\u5ea6\u65b0\u95fb\u6e90\u652f\u6301\u3002<\/li>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u767e\u5ea6\u65b0\u95fb\u6e90\u662f\u767e\u5ea6\u65b0\u95fb\u641c\u7d22\u7684\u4e00\u4e2a\u6570\u636e\u63a5\u53e3\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u83b7\u53d6\u767e\u5ea6\u65b0\u95fb\u7684\u5b9e\u65f6\u6570\u636e\u3002\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06\u60a8\u7684\u7f51\u7ad9\u6216\u5e94\u7528\u63a5\u5165\u767e\u5ea6\u65b0\u95fb\u6e90\uff0c\u5b9e\u73b0\u65b0\u95fb\u6570\u636e\u7684\u5b9e\u65f6\u83b7\u53d6\u3002 \u64cd\u4f5c\u524d\u7684\u51c6\u5907 \u5728\u5f00\u59cb\u64cd\u4f5c\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u5df2\u7ecf\uff1a \u6ce8\u518c\u4e86\u767e\u5ea6\u65b0\u95fb\u6e90\u8d26\u53f7\u3002 \u83b7\u53d6\u4e86API\u5bc6&#8230;<\/p>\n","protected":false},"author":1,"featured_media":166,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-1401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-yun"],"_links":{"self":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/comments?post=1401"}],"version-history":[{"count":1,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1401\/revisions"}],"predecessor-version":[{"id":1402,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1401\/revisions\/1402"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media\/166"}],"wp:attachment":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media?parent=1401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/categories?post=1401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/tags?post=1401"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/topic?post=1401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}