{"id":28068,"date":"2024-11-24T14:55:10","date_gmt":"2024-11-24T06:55:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28068\/"},"modified":"2024-11-24T14:55:10","modified_gmt":"2024-11-24T06:55:10","slug":"node-%e4%b8%ad%e4%bd%bf%e7%94%a8-request-%e8%8e%b7%e5%8f%96-html-%e6%96%87%e6%9c%ac%e5%86%85%e5%ae%b9%e7%bc%96%e7%a0%81%ef%bc%8c%e5%a6%82%e4%bd%95%e9%81%bf%e5%85%8d%e7%bc%96%e7%a0%81%e5%bc%82%e5%b8%b8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28068\/","title":{"rendered":"Node \u4e2d\u4f7f\u7528 Request \u83b7\u53d6 HTML \u6587\u672c\u5185\u5bb9\u7f16\u7801\uff0c\u5982\u4f55\u907f\u514d\u7f16\u7801\u5f02\u5e38\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173139030370666.jpg\" class=\"aligncenter\" title=\"Node \u4e2d\u4f7f\u7528 Request \u83b7\u53d6 HTML \u6587\u672c\u5185\u5bb9\u7f16\u7801\uff0c\u5982\u4f55\u907f\u514d\u7f16\u7801\u5f02\u5e38\uff1f\u63d2\u56fe\" alt=\"Node \u4e2d\u4f7f\u7528 Request \u83b7\u53d6 HTML \u6587\u672c\u5185\u5bb9\u7f16\u7801\uff0c\u5982\u4f55\u907f\u514d\u7f16\u7801\u5f02\u5e38\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 node \u4e2d\u4f7f\u7528 request \u83b7\u53d6\u51c6\u786e\u7684 html \u6587\u672c\u5185\u5bb9\u7f16\u7801\uff1f<\/strong><\/p>\n<p>\u5728 Node \u73af\u5883\u4e0b\uff0c\u4f7f\u7528 Request \u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u901a\u5e38\u4f1a\u9047\u5230\u7f16\u7801\u5f02\u5e38\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u5f00\u53d1\u8005\u53d1\u73b0\u4f7f\u7528 Axios \u66ff\u6362 Request \u53ef\u4ee5\u6709\u6548\u89e3\u51b3\u6b64\u95ee\u9898\u3002<\/p>\n<p>Axios \u662f\u4e00\u4e2a\u57fa\u4e8e Promise \u7684 HTTP \u8bf7\u6c42\u5e93\uff0c\u5728 \u5904\u7406\u7f16\u7801\u5f02\u5e38\u65b9\u9762\u8868\u73b0\u5f97\u66f4\u4e3a\u51fa\u8272\u3002<\/p>\n<p>\u5728\u539f\u6709\u4ee3\u7801\u4e2d\uff0c\u9700\u8981\u5c06\u5982\u4e0b\u4ee3\u7801\u66ff\u6362\u4e3a\u4f7f\u7528 Axios \u83b7\u53d6\u5185\u5bb9\uff1a<\/p>\n<pre>const axios = require('axios')\n\nfunction getGoods () {\n    axios.get('https:\/\/www.58moto.com\/used-car\/1470264')\n        .then(function (response) {\n            console.log(response.data)\n        })\n        .catch(function (error) {\n            console.log(error)\n        })\n}\n\ngetGoods()<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u4f7f\u7528 Axios\uff0c\u53ef\u4ee5\u6b63\u786e\u83b7\u53d6\u7f51\u9875\u7684 HTML \u6587\u672c\u5185\u5bb9\uff0c\u907f\u514d\u56e0\u7f16\u7801\u5f02\u5e38\u5bfc\u81f4\u5185\u5bb9\u9519\u4e71\u6216\u4e0d\u53ef\u8bfb\u7684\u60c5\u51b5\u53d1\u751f\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fNode \u4e2d\u4f7f\u7528 Request \u83b7\u53d6 HTML \u6587\u672c\u5185\u5bb9\u7f16\u7801\uff0c\u5982\u4f55\u907f\u514d\u7f16\u7801\u5f02\u5e38\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728 node \u4e2d\u4f7f\u7528 request \u83b7\u53d6\u51c6\u786e\u7684 html \u6587\u672c\u5185\u5bb9\u7f16\u7801\uff1f \u5728 Node \u73af\u5883\u4e0b\uff0c\u4f7f\u7528 Request \u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u901a\u5e38\u4f1a\u9047\u5230\u7f16\u7801\u5f02\u5e38\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u5f00\u53d1\u8005\u53d1\u73b0\u4f7f\u7528 Axios \u66ff\u6362 Request \u53ef\u4ee5\u6709\u6548\u89e3\u51b3\u6b64\u95ee\u9898\u3002 Axios \u662f\u4e00\u4e2a\u57fa\u4e8e Promise \u7684 HTTP \u8bf7\u6c42\u5e93\uff0c\u5728 \u5904\u7406\u7f16\u7801\u5f02\u5e38\u65b9\u9762\u8868\u73b0\u5f97\u66f4\u4e3a\u51fa\u8272\u3002 \u5728\u539f\u6709\u4ee3\u7801\u4e2d\uff0c\u9700\u8981\u5c06\u5982\u4e0b\u4ee3\u7801\u66ff\u6362\u4e3a\u4f7f\u7528 Axios \u83b7\u53d6\u5185\u5bb9\uff1a const axios = require(&#8216;axios&#8217;) function getGoods () { axios.get(&#8216;https:\/\/www.58moto.com\/used-car\/1470264&#8217;) .then(function (response) { console.log(response.data) }) .catch(function (error) { console.log(error) }) } getGoods() \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u4f7f\u7528 Axios\uff0c\u53ef\u4ee5\u6b63\u786e\u83b7\u53d6\u7f51\u9875\u7684 HTML \u6587\u672c\u5185\u5bb9\uff0c\u907f\u514d\u56e0\u7f16\u7801\u5f02\u5e38\u5bfc\u81f4\u5185\u5bb9\u9519\u4e71\u6216\u4e0d\u53ef\u8bfb\u7684\u60c5\u51b5\u53d1\u751f\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4ee5\u4e0a\u5c31\u662fNode \u4e2d\u4f7f\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-28068","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28068"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28068\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}