{"id":426754,"date":"2021-04-10T10:22:09","date_gmt":"2021-04-10T02:22:09","guid":{"rendered":"http:\/\/4563.org\/?p=426754"},"modified":"2021-04-10T10:22:09","modified_gmt":"2021-04-10T02:22:09","slug":"%e5%a4%a9%e5%a4%a9%e7%9c%8b%e4%bd%a0%e4%bb%ac%e5%88%b6%e4%bd%9c%e5%90%84%e7%a7%8d%e6%91%b8%e9%b1%bc%e7%bd%91%e9%a1%b5%e3%80%82%e6%88%91%e7%9b%b4%e6%8e%a5%e8%b4%a1%e7%8c%ae%e4%b8%80%e4%b8%aa-node","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=426754","title":{"rendered":"\u5929\u5929\u770b\u4f60\u4eec\u5236\u4f5c\u5404\u79cd\u6478\u9c7c\u7f51\u9875\u3002\u6211\u76f4\u63a5\u8d21\u732e\u4e00\u4e2a node \u6293\u53d6\u70ed\u70b9\u7684\u4ee3\u7801\u3002\uff08\u4f4e\u7aef\u7248\u722c\u53d6\u7f51\u9875\u6570\u636e\uff09"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5929\u5929\u770b\u4f60\u4eec\u5236\u4f5c\u5404\u79cd\u6478\u9c7c\u7f51\u9875\u3002\u6211\u76f4\u63a5\u8d21\u732e\u4e00\u4e2a node \u6293\u53d6\u70ed\u70b9\u7684\u4ee3\u7801\u3002\uff08\u4f4e\u7aef\u7248\u722c\u53d6\u7f51\u9875\u6570\u636e\uff09               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : WishMeLz <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u4f11\u606f\u5929\u6ca1\u4e8b\u505a\uff0c\u5c0f\u83dc\u9e21\u4e00\u4e2a\u3002\u8bf7\u591a\u591a\u6307\u6559\u3002<\/p>\n<p>\u521d\u59cb\u5316\u4e00\u4e2a\u8bf7\u6c42\u7684\u65b9\u6cd5<\/p>\n<pre><code>const cheerio = require('cheerio'); const request = require('request'); const iconv = require('iconv-lite'); function http(url, decode = 'utf8') {     return new Promise((resolve, rejext) =&gt; {         request({ url, encoding: null }, function (error, response, body) {             if (!error &amp;&amp; response.statusCode == 200) {                 var buf = iconv.decode(body, decode);\/\/\u83b7\u53d6\u5185\u5bb9\u8fdb\u884c\u8f6c\u7801                 var $ = cheerio.load(buf); \/\/\u521d\u59cb\u5316                 resolve($)             } else {                 rejext(error)             }         });     }) } module.exports = http  <\/code><\/pre>\n<p>\u4f7f\u7528<\/p>\n<pre><code>\/\/ \u5fae\u535a\u70ed\u641c const http = require('.\/http') let url = 'https:\/\/s.weibo.com\/top\/summary' http(url)     .then(res =&gt; {         var $ = res;         var table = $('#pl_top_realtimehot &gt; table &gt; tbody').find('tr .td-02 a')         var resData = []         table.each((i, e) =&gt; {             resData.push({                 index: i,                 title: $(e).text(),                 url: \"https:\/\/s.weibo.com\" + $(e).attr('href')             })          })         console.log(resData);     })     .catch(err =&gt; {         console.log(err);     })  <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>15<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5732413\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u554a\u8fd9\u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732414\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : learningman <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5efa\u8bae\u53d1\u53bb CSDN\uff0c\u4ed6\u4eec\u4e00\u5b9a\u4f1a\u8c22\u8c22\u4f60\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732415\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : j777 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u73a9\u610f\u513f\u4e5f\u503c\u5f97\u53d1\u51fa\u6765\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732416\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : winnerczwx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4eba\u5bb6\u53d1\u51fa\u6765\u53c8\u4e0d\u5f71\u54cd\u4f60\u4eec\u4ec0\u4e48\uff0c \u4e0a\u4f55\u5fc5\u51b7\u5632\u70ed\u8bbd                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732417\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yyyb <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0a\u7684\u4e0a\u53d1\u4e2a\u503c\u5f97\u7684\u73a9\u610f\u513f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732418\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : falcon05 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8d21\u732e\u4e86\u4ee3\u7801\uff0c\u90a3\u6211\u8d21\u732e\u4e00\u4e2a\u70ed\u70b9\uff0cHackerNews \u7684\u65b0\u95fb\u7684\u4e2d\u8bd1\u5217\u8868\uff0curl \u89c4\u5f8b\u662f HN-\u65e5\u671f\uff0c\u6bd4\u5982\uff1a<br \/>https:\/\/hicms.eu.org\/p\/HN-20210410                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732419\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 3dwelcome <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u633a\u597d\u7684\uff0c\u8def\u8fc7\u652f\u6301\u4e00\u4e0b\u3002<br \/>\u5199\u4ee3\u7801\u548c\u5199\u6587\u7ae0\u4e00\u6837\uff0c\u662f\u4e3a\u4e86\u8ba9\u522b\u4eba\u770b\u61c2\uff0c\u4e0d\u662f\u5199\u4e00\u5806\u590d\u6742\u4ee3\u7801\u81ea\u5df1\u4e00\u4e2a\u4eba\u55e8\u3002\u4e3b\u8fd9\u4e2a\u4e00\u773c\u5c31\u80fd\u61c2\uff0c\u8fd9\u70b9\u5c31\u5f88\u8d5e\u3002<br \/>\u8c01\u90fd\u662f\u65b0\u624b\u9636\u6bb5\u8fc7\u6765\u7684\uff0c\u552f\u6709\u624d\u80fd\u7b11\u5230\u6700\u540e\uff0c\u4e3b\u52a0\u6cb9\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732420\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lxxyx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u633a\u597d\u7684\uff0c\u652f\u6301 +1 \u3002<\/p>\n<p>\u8c01\u90fd\u6709\u83dc\u9e1f\u7684\u65f6\u5019\uff0c\u80fd\u5199\u51fa\u6bd4\u8f83\u5de5\u6574\u53ef\u7528\u7684\u4ee3\u7801\u5df2\u7ecf\u5f88\u4e86\u4e0d\u8d77\u4e86\uff0c\u52a0\u6cb9\uff01                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732421\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : labulaka521 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b66\u5230\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732422\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Smurf <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             gogogo\uff0c \u8bf7\u628a\u4fdd\u62a4\u6253\u5728\u516c\u5c4f\u4e0a\u3002\u8d44\u74f7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732423\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ji39 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8c01\u8bf7\u89e3\u6790\u4e0b return new Promise \u8fd9\u884c\u4ee3\u7801                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732424\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : WishMeLz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ji39 \u5f02\u6b65\u5440                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732425\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : WishMeLz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @learningman \u4e0d\u6562\u53bb\uff0c\u732e\u4e11\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732426\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : WishMeLz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @3dwelcome \u591a\u8c22\uff0c\u563f\u563f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5732427\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : WishMeLz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Lxxyx \u591a\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5929\u5929\u770b\u4f60\u4eec\u5236\u4f5c\u5404\u79cd\u6478\u9c7c\u7f51\u9875\u3002\u6211\u76f4\u63a5&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/426754"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=426754"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/426754\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=426754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=426754"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=426754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}