加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
decrypt.txt 128.96 KB
一键复制 编辑 原始数据 按行查看 历史
双反光 提交于 2022-05-08 12:58 . 11
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="canonical" href="https://blog.csdn.net/nh18304030935/article/details/78285151"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="report" content='{"pid": "blog", "spm":"1001.2101"}'>
<meta name="referrer" content="always">
<meta http-equiv="Cache-Control" content="no-siteapp" /><link rel="alternate" media="handheld" href="#" />
<meta name="shenma-site-verification" content="5a59773ab8077d4a62bf469ab966a63b_1497598848">
<meta name="applicable-device" content="pc">
<link href="https://g.csdnimg.cn/static/logo/favicon32.ico" rel="shortcut icon" type="image/x-icon" />
<title>nodejs自带的请求方法--http.request_无命可取的博客-CSDN博客_http.request nodejs</title>
<script>
(function(){
var el = document.createElement("script");
el.src = "https://s3a.pstatp.com/toutiao/push.js?1abfa13dfe74d72d41d83c86d240de427e7cac50c51ead53b2e79d40c7952a23ed7716d05b4a0f683a653eab3e214672511de2457e74e99286eb2c33f4428830";
el.id = "ttzz";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(el, s);
})(window)
</script>
<meta name="keywords" content="http.request nodejs">
<meta name="csdn-baidu-search" content='{"autorun":true,"install":true,"keyword":"http.request nodejs"}'>
<meta name="description" content="本文是接着前面的,用nodejs获取到本地文件的内容之后的操作。当获取完本地文件的内容后,假设内容为相关的url链接,用ajax请求获取数据,这种方法是基于浏览器的,所以运行效率都是依赖于浏览器。但是用nodejs也可以实现获取数据,并且是基于操作系统的,效率上远远超过浏览器方式。下面来细说如何操作:1.先声明一个通用方法来进行数据的请求var http=require(&quot;ht">
<script src="//g.csdnimg.cn/tingyun/1.8.5/blog.js" type='text/javascript'></script>
<link rel="stylesheet" type="text/css" href="https://csdnimg.cn/release/blogv2/dist/pc/css/detail_enter-d9aa713720.min.css">
<style>
#content_views pre{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#content_views pre code{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
<script type="application/ld+json">{"@context":"https://ziyuan.baidu.com/contexts/cambrian.jsonld","@id":"https://blog.csdn.net/nh18304030935/article/details/78285151","appid":"1638831770136827","pubDate":"2017-10-19T15:10:41","title":"nodejs自带的请求方法--http.request_无命可取的博客-CSDN博客_http.request nodejs","upDate":"2017-10-19T15:10:41"}</script>
<link rel="stylesheet" type="text/css" href="https://csdnimg.cn/release/blogv2/dist/pc/themesSkin/skin3-template/skin3-template-762f7595fd.min.css">
<script src="https://csdnimg.cn/public/common/libs/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var isCorporate = false;//注释删除enterprise
var username = "nh18304030935";
var skinImg = "white";
var blog_address = "https://blog.csdn.net/nh18304030935";
var currentUserName = "";
var isOwner = false;
var loginUrl = "http://passport.csdn.net/account/login?from=https://blog.csdn.net/nh18304030935/article/details/78285151";
var blogUrl = "https://blog.csdn.net/";
var avatar = "https://profile.csdnimg.cn/7/6/7/3_nh18304030935";
var articleTitle = "nodejs自带的请求方法--http.request";
var articleDesc = "本文是接着前面的,用nodejs获取到本地文件的内容之后的操作。当获取完本地文件的内容后,假设内容为相关的url链接,用ajax请求获取数据,这种方法是基于浏览器的,所以运行效率都是依赖于浏览器。但是用nodejs也可以实现获取数据,并且是基于操作系统的,效率上远远超过浏览器方式。下面来细说如何操作:1.先声明一个通用方法来进行数据的请求var http=require(\&quot;ht";
var articleTitles = "nodejs自带的请求方法--http.request_无命可取的博客-CSDN博客_http.request nodejs";
var nickName = "无命可取";
var articleDetailUrl = "https://blog.csdn.net/nh18304030935/article/details/78285151";
if(window.location.host.split('.').length == 3) {
blog_address = blogUrl + username;
}
var skinStatus = "White";
var blogStaticHost = "https://csdnimg.cn/release/blogv2/"
var isShowConcision = false;
var isCookieConcision = false
var isHasDirectoryModel = false
var isShowSideModel = false
var isShowDirectoryModel = true
function getCookieConcision(sName){
var allCookie = document.cookie.split("; ");
for (var i=0; i < allCookie.length; i++){
var aCrumb = allCookie[i].split("=");
if (sName == aCrumb[0])
return aCrumb[1];
}
return null;
}
if (getCookieConcision('blog_details_concision') && getCookieConcision('blog_details_concision') == 0){
isCookieConcision = true
isShowSideModel = true
isShowDirectoryModel = false
}
</script>
<script src="https://g.csdnimg.cn/??fixed-sidebar/1.1.6/fixed-sidebar.js" type="text/javascript"></script>
<script src='//g.csdnimg.cn/common/csdn-report/report.js' type='text/javascript'></script>
<link rel="stylesheet" type="text/css" href="https://csdnimg.cn/public/sandalstrap/1.4/css/sandalstrap.min.css">
<style>
.MathJax, .MathJax_Message, .MathJax_Preview{
display: none
}
</style>
<script src="https://dup.baidustatic.com/js/ds.js"></script>
</head>
<body class="nodata " style="">
<script>
var toolbarSearchExt = '{"landingWord":["http.request nodejs"],"queryWord":"","tag":["javascript","ajax","nodejs","数据"],"title":"nodejs自带的请求方法--http.request"}';
</script>
<script src="https://g.csdnimg.cn/common/csdn-toolbar/csdn-toolbar.js" type="text/javascript"></script>
<script>
(function(){
var bp = document.createElement('script');
var curProtocol = window.location.protocol.split(':')[0];
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
}
else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(bp, s);
})();
</script>
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/pc/css/blog_code-01256533b5.min.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/chart-3456820cac.css" />
<script>
var articleId = 78285151;
var commentscount = 0;
var curentUrl = "https://blog.csdn.net/nh18304030935/article/details/78285151";
var myUrl = "https://my.csdn.net/";
var highlight = ["javascript","ajax","http","nodejs","数据","request","方法","请求","自带","--"];//高亮数组
var isRecommendModule = true;
var isBaiduPre = true;
var baiduCount = 2;
var share_card_url = "https://app-blog.csdn.net/share?article_id=78285151&username=nh18304030935"
var articleType = 1;
var baiduKey = "http.request nodejs";
var userNewReport = true;
var needInsertBaidu = true;
var recommendRegularDomainArr = ["blog.csdn.net/.+/article/details/","download.csdn.net/download/","edu.csdn.net/course/detail/","ask.csdn.net/questions/","bbs.csdn.net/topics/","www.csdn.net/gather_.+/"]
var codeStyle = "";
var baiduSearchType = "baidulandingword";
var canRead = true;
var blogMoveHomeArticle = false;
var showPcWindowAd = false;
var showHeadWord = true;
var showSearchText = "";
var linkPage = true;
var articleSource = 1;
var articleReport = '{"pid": "blog", "spm":"1001.2101"}';
var isShowToQuestion = false;
var baiduSearchChannel = 'pc_relevant'
var baiduSearchIdentification = '.pc_relevant_paycolumn_v3'
var distRequestId = '1651051593477_31971'
var initRewardObject = {
giver: currentUserName,
anchor: username,
articleId: articleId,
sign: ''
}
var isLikeStatus = false;
var isUnLikeStatus = false;
var studyLearnWord = "";
var isCurrentUserVip = false;
var commentIsNewBeat = "control"
</script>
<div class="main_father clearfix d-flex justify-content-center " style="height:100%;">
<div class="container clearfix " id="mainBox">
<script>
if(!isCookieConcision){
$('.main_father').removeClass('mainfather-concision')
$('.main_father .container').removeClass('container-concision')
}
</script>
<main>
<script type="text/javascript">
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
var r = window.location.search.substr(1).match(reg); //匹配目标参数
if( r != null ) return decodeURIComponent( r[2] ); return '';
}
function stripscript(s){
var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?%]")
var rs = "";
for (var i = 0; i < s.length; i++) {
rs = rs+s.substr(i, 1).replace(pattern, '');
}
return rs;
}
var blogHotWords = stripscript(getQueryString('utm_term')).length > 1 ? stripscript(getQueryString('utm_term')) : ''
</script>
<div class="blog-content-box">
<div class="article-header-box">
<div class="article-header">
<div class="article-title-box">
<h1 class="title-article" id="articleContentId">nodejs自带的请求方法--http.request</h1>
</div>
<div class="article-info-box">
<div class="article-bar-top">
<img class="article-type-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/original.png" alt="">
<div class="bar-content">
<a class="follow-nickName " href="https://blog.csdn.net/nh18304030935" target="_blank" rel="noopener">无命可取</a>
<img class="article-time-img article-heard-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newCurrentTime2.png" alt="">
<span class="time">于&nbsp;2017-10-19 15:10:41&nbsp;发布</span>
<img class="article-read-img article-heard-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/articleReadEyes2.png" alt="">
<span class="read-count">5483</span>
<a id="blog_detail_zk_collection" class="un-collection" data-report-click='{"mod":"popu_823","spm":"1001.2101.3001.4232","ab":"new"}'>
<img class="article-collect-img article-heard-img un-collect-status isdefault" style="display:inline-block" src="https://csdnimg.cn/release/blogv2/dist/pc/img/tobarCollect2.png" alt="">
<img class="article-collect-img article-heard-img collect-status isactive" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/tobarCollectionActive2.png" alt="">
<span class="name">收藏</span>
<span class="get-collection">
2
</span>
</a>
</div>
</div>
<div class="blog-tags-box">
<div class="tags-box artic-tag-box">
<span class="label">分类专栏:</span>
<a class="tag-link" href="https://blog.csdn.net/nh18304030935/category_6888798.html" target="_blank" rel="noopener">web前端</a>
<span class="label">文章标签:</span>
<a data-report-click='{"mod":"popu_626","spm":"1001.2101.3001.4223","strategy":"javascript","ab":"new"}' class="tag-link" href="https://so.csdn.net/so/search/s.do?q=javascript&amp;t=blog&amp;o=vip&amp;s=&amp;l=&amp;f=&amp;viparticle=" target="_blank" rel="noopener">javascript</a>
<a data-report-click='{"mod":"popu_626","spm":"1001.2101.3001.4223","strategy":"ajax","ab":"new"}' class="tag-link" href="https://so.csdn.net/so/search/s.do?q=ajax&amp;t=blog&amp;o=vip&amp;s=&amp;l=&amp;f=&amp;viparticle=" target="_blank" rel="noopener">ajax</a>
<a data-report-click='{"mod":"popu_626","spm":"1001.2101.3001.4223","strategy":"nodejs","ab":"new"}' class="tag-link" href="https://so.csdn.net/so/search/s.do?q=nodejs&amp;t=blog&amp;o=vip&amp;s=&amp;l=&amp;f=&amp;viparticle=" target="_blank" rel="noopener">nodejs</a>
<a data-report-click='{"mod":"popu_626","spm":"1001.2101.3001.4223","strategy":"数据","ab":"new"}' class="tag-link" href="https://so.csdn.net/so/search/s.do?q=%E6%95%B0%E6%8D%AE&amp;t=blog&amp;o=vip&amp;s=&amp;l=&amp;f=&amp;viparticle=" target="_blank" rel="noopener">数据</a>
</div>
</div>
<div class="slide-content-box">
<div class="article-copyright">
<div class="creativecommons">
版权声明:本文为博主原创文章,遵循<a href="http://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="noopener"> CC 4.0 BY-SA </a>版权协议,转载请附上原文出处链接和本声明。
</div>
<div class="article-source-link">
本文链接:<a href="https://blog.csdn.net/nh18304030935/article/details/78285151" target="_blank">https://blog.csdn.net/nh18304030935/article/details/78285151</a>
</div>
</div>
</div>
<div class="operating">
<a class="href-article-edit slide-toggle">版权</a>
</div>
</div>
</div>
</div>
<div id="blogColumnPayAdvert">
<div class="column-group">
<div class="column-group-item column-group0 column-group-item-one">
<div class="item-l">
<a class="item-target" href="https://blog.csdn.net/nh18304030935/category_6888798.html" target="_blank" title="web前端"
data-report-view='{"spm":"1001.2101.3001.6332"}'
data-report-click='{"spm":"1001.2101.3001.6332"}'>
<img class="item-target" src="https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64" alt="">
<span class="title item-target">
<span>
<span class="tit">web前端</span>
<span class="dec">专栏收录该内容</span>
</span>
</span>
</a>
</div>
<div class="item-m">
<span>6 篇文章</span>
<span>0 订阅</span>
</div>
<div class="item-r">
<a class="item-target article-column-bt articleColumnFreeBt" data-id="6888798">订阅专栏</a>
</div>
</div>
</div>
</div>
<article class="baidu_pl">
<div id="article_content" class="article_content clearfix">
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-163de54645.css">
<div id="content_views" class="htmledit_views">
<p>本文是接着前面的&#xff0c;用nodejs获取到本地文件的内容之后的操作。</p>
<p>当获取完本地文件的内容后&#xff0c;假设内容为相关的url链接&#xff0c;用ajax请求获取数据&#xff0c;这种方法是基于浏览器的&#xff0c;所以运行效率都是依赖于浏览器。</p>
<p>但是用nodejs也可以实现获取数据&#xff0c;并且是基于操作系统的&#xff0c;效率上远远超过浏览器方式。</p>
<p><a target="_blank" href="http://nodejs.cn/api/http.html#http_http_request_options_callback" rel="noopener noreferrer">本文使用的http.request()方法的API</a></p>
<p>下面来细说如何操作&#xff1a;</p>
<p>1.先声明一个通用方法来进行数据的请求</p>
<p></p>
<pre><code class="language-javascript">var http&#61;require(&#34;http&#34;); //导入需要的http库
function HttpRequest(option,callback){ //option设置请求的请求头&#xff0c;callback请求数据回调函数
var con&#61;&#39;&#39;; //存放请求后的数据
var req&#61;http.request(option,function(res){ //http。request方法用于获取数据
res.setEncoding(&#39;utf-8&#39;); //设置响应字符集
var resListener&#61;setTimeout(function(){ //添加响应监听&#xff0c;20s后没有响应信息返回自动结束响应&#xff0c;并返回空数据
res.destroy(); //结束响应
con&#61;&#39;&#39;;
callback(con);
},20000);
res.on(&#39;data&#39;,function(chuck){ //响应返回数据&#xff0c;并接受
if(chuck) con&#43;&#61;chuck;
}).on(&#39;end&#39;,function(){ //数据返回完毕
clearTimeout(resListener);
callback(con);
});
});
req.on(&#39;error&#39;,function(e){ //响应出错调用函数
console.log(&#39;错误为&#xff1a;&#39;&#43;e.message);
});
req.write(&#39;&#39;); //发送请求
req.end(); //结束请求
}</code></pre>2.写一个方法调用上面的方法&#xff1a;
<p></p>
<p></p>
<pre><code class="language-javascript">function doEngine(data,callback){
var option&#61;{ //设置请求头信息
host:data.host, //域名
path:data.path, //资源地址
method:&#39;GET&#39;, //请求方式
headers:{ //请求头信息
&#39;Accept&#39;:&#39;text/html,application/xhtml&#43;xml,application/xml;q&#61;0.9,image/webp,image/apng,*/*;q&#61;0.8&#39;,
&#39;User-Agent&#39;:&#39;Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36&#39;
}
}
HttpRequest(option,function(obj){
callback(obj);
});
}</code></pre>
<br /> 3.写一个主函数运行&#xff1a;
<p></p>
<p></p>
<pre><code class="language-javascript">function run(data){
if(data){
//data&#61; ....(data); 对数据进行适当的处理
doEngine(data,function(obj){
if(obj){
//对返回的数据进行相应的处理&#xff0c;不细说&#xff0c;根据实际情况而定
}
});
}
}</code></pre>
<br /> 4.最后调用之前写的getContent()方法来获取要请求的请求头信息
<p></p>
<p><a target="_blank" href="http://blog.csdn.net/nh18304030935/article/details/77312213" rel="noopener noreferrer">nodeJS中大文件读写操作--Stream流</a></p>
<p></p>
<pre><code class="language-javascript">getContent(rs,run);</code></pre>
<br />
<br />
<br />
<p></p>
</div>
</div>
<div id="treeSkill"></div>
</article>
<script>
$(function() {
setTimeout(function () {
var mathcodeList = document.querySelectorAll('.htmledit_views img.mathcode');
if (mathcodeList.length > 0) {
var testImg = new Image();
testImg.onerror = function () {
mathcodeList.forEach(function (item) {
$(item).before('<span class="img-codecogs">\\(' + item.alt + '\\)</span>');
$(item).remove();
})
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
testImg.src = mathcodeList[0].src;
}
}, 1000)
})
</script>
</div>
<div class="more-toolbox-new" id="toolBarBox">
<div class="left-toolbox">
<div class="toolbox-left">
<div class="profile-box"><a class="profile-href" target="_blank" href="https://blog.csdn.net/nh18304030935"><img class="profile-img" src="https://profile.csdnimg.cn/7/6/7/3_nh18304030935"><span class="profile-name">无命可取</span></a></div>
<div class="profile-attend">
<a class="tool-attend tool-bt-button tool-bt-attend" href="javascript:;" data-report-view='{"mod":"1592215036_002","spm":"1001.2101.3001.4232","extend1":"关注"}'>关注</a>
<a class="tool-item-follow active-animation" style="display:none;">关注</a>
</div>
</div>
<div class="toolbox-middle">
<ul class="toolbox-list">
<li class="tool-item tool-item-size tool-active is-like" id="is-like">
<a class="tool-item-href">
<img style="display:none;" id="is-like-imgactive-animation-like" class="animation-dom active-animation" src="https://csdnimg.cn/release/blogv2/dist/pc/img/tobarThumbUpactive.png" alt="">
<img class="isactive" style="display:none" id="is-like-imgactive" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newHeart2021Active.png" alt="">
<img class="isdefault" style="display:block" id="is-like-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newHeart2021White.png" alt="">
<span id="spanCount" class="count ">
1
</span>
</a>
<div class="tool-hover-tip"><span class="text space">点赞</span></div>
</li>
<li class="tool-item tool-item-size tool-active is-unlike" id="is-unlike">
<a class="tool-item-href">
<img class="isactive" style="margin-right:0px;display:none" id="is-unlike-imgactive" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newUnHeart2021Active.png" alt="">
<img class="isdefault" style="margin-right:0px;display:block" id="is-unlike-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newUnHeart2021White.png" alt="">
<span id="unlikeCount" class="count "></span>
</a>
<div class="tool-hover-tip"><span class="text space">踩</span></div>
</li>
<li class="tool-item tool-item-size tool-active tool-item-comment">
<a class="tool-item-href" href="#commentBox" data-report-click='{"spm":"1001.2101.3001.7009"}'>
<img class="isdefault" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newComment2021White.png" alt="">
<span class="count">
0
</span>
</a>
<div class="tool-hover-tip"><span class="text space">评论</span></div>
</li>
<li class="tool-item tool-item-size tool-active is-collection ">
<a class="tool-item-href" href="javascript:;" data-report-click='{"mod":"popu_824","spm":"1001.2101.3001.4130","ab":"new"}'>
<img style="display:none" id="is-collection-img-collection" class="animation-dom active-animation" src="https://csdnimg.cn/release/blogv2/dist/pc/img/tobarCollectionActive.png" alt="">
<img class="isdefault" id="is-collection-img" style="display:block" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newCollectWhite.png" alt="">
<img class="isactive" id="is-collection-imgactive" style="display:none" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newCollectActive.png" alt="">
<span class="count get-collection " id="get-collection">
2
</span>
</a>
<div class="tool-hover-tip"><span class="text space">收藏</span></div>
</li>
<li class="tool-item tool-item-size tool-active tool-item-reward">
<a class="tool-item-href" href="javascript:;" data-report-click='{"mod":"popu_830","spm":"1001.2101.3001.4237","dest":"","ab":"new"}'>
<img class="isdefault reward-bt" id="rewardBtNew" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newRewardWhite.png" alt="打赏">
<span class="count"></span>
</a>
<div class="tool-hover-tip"><span class="text space">打赏</span></div>
</li>
<li class="tool-item tool-item-bar">
</li>
<li class="tool-item tool-item-size tool-active tool-QRcode" id="tool-share">
<a class="tool-item-href" href="javascript:;" data-report-click='{"mod":"1582594662_002","spm":"1001.2101.3001.4129","ab":"new"}'>
<img class="isdefault" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newShareWhite.png" alt="">
</a>
<div class="QRcode" id="tool-QRcode">
<p class="title">
扫一扫,分享内容
</p>
<div id='shareCode'></div>
<a id="copyPosterUrl" class="url" data-report-click='{"spm":"1001.2101.3001.7493"}' data-report-view='{"spm":"1001.2101.3001.7493"}'>点击复制链接</a>
</div>
</li>
</ul>
</div>
<div class="toolbox-right">
<div class="tool-directory">
<a class="bt-columnlist-show"
data-id="6888798"
data-free="true"
data-subscribe="false"
data-title="web前端"
data-img="https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64"
data-url="https://blog.csdn.net/nh18304030935/category_6888798.html"
data-sum="6"
data-people="0"
data-price="0"
data-oldprice="0"
data-join="false"
data-studyvip="false"
data-studysubscribe="false"
data-report-view='{"spm":"1001.2101.3001.6334","extend1":"专栏目录"}'
data-report-click='{"spm":"1001.2101.3001.6334","extend1":"专栏目录"}'
>专栏目录</a>
</div>
</div>
</div>
</div>
<script type=text/javascript crossorigin src="https://csdnimg.cn/release/phoenix/production/qrcode-7c90a92189.min.js"></script>
<script src="//g.csdnimg.cn/??sharewx/1.2.1/sharewx.js" type="text/javascript"></script>
<script type="text/javascript" crossorigin src="https://g.csdnimg.cn/user-login/3.0.1/user-login.js"></script>
<script type="text/javascript" crossorigin src="https://g.csdnimg.cn/collection-box/2.0.8/collection-box.js"></script>
<div class="first-recommend-box recommend-box">
<div class="recommend-item-box type_download clearfix" data-url="https://download.csdn.net/download/deeplies/9649031" data-report-view='{"ab":"new","spm":"1001.2101.3001.6661.1","mod":"popu_871","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant_t0.none-task-download-2~default~CTRLIST~Paid-1.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"1","strategy":"2~default~CTRLIST~Paid","dest":"https://download.csdn.net/download/deeplies/9649031"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://download.csdn.net/download/deeplies/9649031" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6661.1","mod":"popu_871","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant_t0.none-task-download-2~default~CTRLIST~Paid-1.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"1","strategy":"2~default~CTRLIST~Paid","dest":"https://download.csdn.net/download/deeplies/9649031"}' data-report-query='spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-download-2%7Edefault%7ECTRLIST%7EPaid-1.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant_t0.none-task-download-2%7Edefault%7ECTRLIST%7EPaid-1.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">通过<em>NodeJS</em>中的<em>http</em>.get() 和 <em>http</em>.<em>request</em>()模块两种<em>方法</em>,调用中国天气api</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info display-flex">
<span class="info-block">10-09</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://download.csdn.net/download/deeplies/9649031" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6661.1","mod":"popu_871","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant_t0.none-task-download-2~default~CTRLIST~Paid-1.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"1","strategy":"2~default~CTRLIST~Paid","dest":"https://download.csdn.net/download/deeplies/9649031"}' data-report-query='spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-download-2%7Edefault%7ECTRLIST%7EPaid-1.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant_t0.none-task-download-2%7Edefault%7ECTRLIST%7EPaid-1.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">通过 <em>NodeJS</em>中的<em>http</em>.get 和 <em>http</em>.<em>request</em>模块两种<em>方法</em>,调用中国天气api</div>
</a>
</div>
</div>
</div>
</div>
<script src="https://csdnimg.cn/release/blogv2/dist/components/js/pc_wap_commontools-5e28c4e010.min.js" type="text/javascript" async></script>
<div class="second-recommend-box recommend-box">
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/anwvkp1505/article/details/101945649" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.1","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-1.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"1","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/anwvkp1505/article/details/101945649"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/anwvkp1505/article/details/101945649" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.1","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-1.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"1","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/anwvkp1505/article/details/101945649"}' data-report-query='spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1"><em>nodejs</em>的<em>http</em>.<em>request</em>使用post方式提交<em>数据</em><em>请求</em></div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/anwvkp1505" target="_blank"><span class="blog-title"></span></a>
</div>
<div class="info display-flex">
<span class="info-block time">11-09</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
1041
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/anwvkp1505/article/details/101945649" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.1","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-1.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"1","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/anwvkp1505/article/details/101945649"}' data-report-query='spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">官方api文档 <em>http</em>://<em>nodejs</em>.org/docs/v0.6.1/api/<em>http</em>.html#<em>http</em>.<em>request</em>虽然也有POST例子,但是并不完整。
直接上代码:<em>http</em>_post.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...</div>
</a>
</div>
</div>
</div>
</div>
<a id="commentBox" name="commentBox"></a>
<div id="pcCommentBox" class="comment-box comment-box-new unlogin-comment-box-new">
<div class="unlogin-comment-model">
<span class="unlogin-comment-tit">参与评论</span>
<span class="unlogin-comment-text">您还未登录,请先</span>
<span class="unlogin-comment-bt">登录</span>
<span class="unlogin-comment-text">后发表或查看评论</span>
</div>
</div>
<div class="recommend-box insert-baidu-box recommend-box-style">
<div class="recommend-item-box clearfix no-index" style="display:none"></div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_30619101/article/details/97720710" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.2","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-2.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"2","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_30619101/article/details/97720710"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_30619101/article/details/97720710" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.2","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-2.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"2","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_30619101/article/details/97720710"}' data-report-query='spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">[转]<em>nodejs</em>使用<em>request</em>发送<em>http</em><em>请求</em></div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_30619101" target="_blank"><span class="blog-title">weixin_30619101的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">03-20</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
99
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_30619101/article/details/97720710" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.2","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-2.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"2","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_30619101/article/details/97720710"}' data-report-query='spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-2.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">本文转自:<em>http</em>s://blog.csdn.net/dreamer2020/article/details/52074516/
在<em>nodejs</em>的开发中,有时需要后台去调用其他服务器的接口,这个时候,就需要发送<em>HTTP</em><em>请求</em>了。有一个简单的工具可以用,Simplified <em>HTTP</em> <em>request</em> client,可以比较方便的模拟<em>请求</em>。
安装npm install <em>--</em>save <em>request</em>1...</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_download clearfix" data-url="https://download.csdn.net/download/weixin_38724247/13039629" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.3","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~CTRLIST~Rate-3.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"3","strategy":"2~default~CTRLIST~Rate","dest":"https://download.csdn.net/download/weixin_38724247/13039629"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://download.csdn.net/download/weixin_38724247/13039629" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.3","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~CTRLIST~Rate-3.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"3","strategy":"2~default~CTRLIST~Rate","dest":"https://download.csdn.net/download/weixin_38724247/13039629"}' data-report-query='spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">node.js中的<em>http</em>.<em>request</em><em>方法</em>使用说明</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info display-flex">
<span class="info-block">10-25</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://download.csdn.net/download/weixin_38724247/13039629" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.3","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~CTRLIST~Rate-3.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"3","strategy":"2~default~CTRLIST~Rate","dest":"https://download.csdn.net/download/weixin_38724247/13039629"}' data-report-query='spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">主要介绍了node.js中的<em>http</em>.<em>request</em><em>方法</em>使用说明,本文介绍了<em>http</em>.<em>request</em>的<em>方法</em>说明、语法、接收参数、使用实例和实现源码需要的朋友可以参考下</div>
</a>
</div>
</div>
</div>
<dl id="recommend-item-box-tow" class="recommend-item-box type_blog clearfix">
</dl>
<div class="recommend-item-box type_download clearfix" data-url="https://download.csdn.net/download/weixin_38605133/14008465" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.4","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~CTRLIST~Rate-4.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"4","strategy":"2~default~CTRLIST~Rate","dest":"https://download.csdn.net/download/weixin_38605133/14008465"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://download.csdn.net/download/weixin_38605133/14008465" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.4","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~CTRLIST~Rate-4.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"4","strategy":"2~default~CTRLIST~Rate","dest":"https://download.csdn.net/download/weixin_38605133/14008465"}' data-report-query='spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-4.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-4.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">详解<em>nodejs</em>通过代理(proxy)发送<em>http</em><em>请求</em>(<em>request</em>)</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info display-flex">
<span class="info-block">01-02</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://download.csdn.net/download/weixin_38605133/14008465" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.4","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~CTRLIST~Rate-4.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"4","strategy":"2~default~CTRLIST~Rate","dest":"https://download.csdn.net/download/weixin_38605133/14008465"}' data-report-query='spm=1001.2101.3001.6650.4&utm_medium=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-4.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ERate-4.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">有可能有这样的需求,需要node作为web服务器通过另外一台<em>http</em>/<em>http</em>s代理服务器发<em>http</em>或者<em>http</em>s<em>请求</em>,废话不多说直接上代码大家都懂的:
var <em>http</em> = require(&#39;<em>http</em>&#39;)
var opt = {
host:&#39;这里放代理服务器的ip或者域名&#39;,
port:&#39;这里放代理服务器的端口号&#39;,
method:&#39;POST&#39;,//这里是发送的<em>方法</em>
path:&#39; <em>http</em>s://www.google.com&#39;, //这里是访问的路径
headers:{
//这里放期望发送出去的<em>请求</em>头
}
}
//以下是接受<em>数据</em>的代码
var body = &#39;&#39;;
var</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/dreamer2020/article/details/52074516" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.5","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-5.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"5","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/dreamer2020/article/details/52074516"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/dreamer2020/article/details/52074516" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.5","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-5.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"5","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/dreamer2020/article/details/52074516"}' data-report-query='spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-5.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-5.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1"><em>nodejs</em>使用<em>request</em>发送<em>http</em><em>请求</em></div>
<div class="tag">热门推荐</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/dreamer2020" target="_blank"><span class="blog-title">dreamer2020的专栏</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">07-31</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
12万+
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/dreamer2020/article/details/52074516" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.5","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-5.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"5","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/dreamer2020/article/details/52074516"}' data-report-query='spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-5.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-5.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">在<em>nodejs</em>的开发中,有时需要后台去调用其他服务器的接口,这个时候,就需要发送<em>HTTP</em><em>请求</em>了。有一个简单的工具可以用,Simplified <em>HTTP</em> <em>request</em> client,可以比较方便的模拟<em>请求</em>。安装npm install <em>--</em>save <em>request</em>使用最简单的GET<em>请求</em>,用法如下:var <em>request</em> = require(&#39;<em>request</em>&#39;);
<em>request</em>(&#39;<em>http</em>://www</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_30764883/article/details/95955604" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.6","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-6.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"6","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_30764883/article/details/95955604"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_30764883/article/details/95955604" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.6","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-6.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"6","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_30764883/article/details/95955604"}' data-report-query='spm=1001.2101.3001.6650.6&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-6.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-6.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">Node.js中的<em>http</em>.<em>request</em><em>方法</em>的使用说明</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_30764883" target="_blank"><span class="blog-title">weixin_30764883的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">01-13</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
69
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_30764883/article/details/95955604" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.6","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-6.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"6","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_30764883/article/details/95955604"}' data-report-query='spm=1001.2101.3001.6650.6&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-6.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-6.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1"><em>方法</em>说明:
函数的功能室作为客户端向<em>HTTP</em>服务器发起<em>请求</em>。
语法:
<em>http</em>.get(options, callback)
由于该<em>方法</em>属于<em>http</em>模块,使用前需要引入<em>http</em>模块(var <em>http</em>= require(&ldquo;<em>http</em>&rdquo;) )
接收参数:
option 数组对象,包含以下参数:
host: 表示<em>请求</em>网站的域名或IP地址(请...</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/sriting/article/details/79632467" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.7","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-7.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"7","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/sriting/article/details/79632467"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/sriting/article/details/79632467" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.7","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-7.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"7","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/sriting/article/details/79632467"}' data-report-query='spm=1001.2101.3001.6650.7&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">node.js学习笔记<em>--</em><em>HTTP</em>之<em>request</em><em>请求</em></div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/sriting" target="_blank"><span class="blog-title">sriting的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">03-20</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
2291
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/sriting/article/details/79632467" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.7","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-7.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"7","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/sriting/article/details/79632467"}' data-report-query='spm=1001.2101.3001.6650.7&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-7.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">注:此博客是在学习进击Node.js基础(一)这门课程时的学习笔记,感谢Scott老师的课程。
var <em>http</em> = require(&#39;<em>http</em>&#39;)
var querystring = require(&#39;querystring&#39;) //这个库可以把对象序列化
var postData = querystring.stringify({
&#39;content&#39;:&#39;来测试一下评论的代码~&#39;,...</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_43742708/article/details/116058467" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.8","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-8.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"8","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_43742708/article/details/116058467"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_43742708/article/details/116058467" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.8","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-8.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"8","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_43742708/article/details/116058467"}' data-report-query='spm=1001.2101.3001.6650.8&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-8.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-8.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">Node之<em>HTTP</em>模块(<em>request</em>对象解析、response对象解析、图片上传)</div>
<div class="tag">最新发布</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_43742708" target="_blank"><span class="blog-title">欢迎访问我的主页:https://www.bookbook.cc</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">04-24</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
288
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_43742708/article/details/116058467" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.8","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-8.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"8","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_43742708/article/details/116058467"}' data-report-query='spm=1001.2101.3001.6650.8&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-8.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-8.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">Node之<em>Http</em>模块
<em>request</em>对象解析、response对象解析
<em>http</em>实现文件上传</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_43866709/article/details/103563173" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.9","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-9.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"9","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_43866709/article/details/103563173"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_43866709/article/details/103563173" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.9","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-9.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"9","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_43866709/article/details/103563173"}' data-report-query='spm=1001.2101.3001.6650.9&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-9.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-9.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">sqoop将Oracle<em>数据</em>接入到hive中中文乱码问题</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_43866709" target="_blank"><span class="blog-title">weixin_43866709的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">12-16</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
609
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_43866709/article/details/103563173" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.9","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-9.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"9","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_43866709/article/details/103563173"}' data-report-query='spm=1001.2101.3001.6650.9&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-9.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-9.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">今天使用sqoop从Oracle中接入<em>数据</em>,有一个字段中文乱码,跟Oracle那边确认是UTF8格式编码。
于是开始进行转码:
1.convert(字段名,&#39;ZHS16GBK&#39;,&#39;UTF8&#39;)
问题解决了。
2.其他编码格式还有US7ASCII
...</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_41474332/article/details/102633912" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.10","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-10.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"10","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_41474332/article/details/102633912"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_41474332/article/details/102633912" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.10","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-10.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"10","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_41474332/article/details/102633912"}' data-report-query='spm=1001.2101.3001.6650.10&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-10.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-10.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1"><em>Http</em><em>Request</em> (入门)</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_41474332" target="_blank"><span class="blog-title">weixin_41474332的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">10-19</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
1166
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_41474332/article/details/102633912" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.10","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-10.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"10","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_41474332/article/details/102633912"}' data-report-query='spm=1001.2101.3001.6650.10&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-10.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-10.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1"><em>Request</em>学习
学习目标
1.能够使用<em>Request</em>对象获取<em>HTTP</em>协议<em>请求</em>内容(掌握)(包含<em>请求</em>行、<em>请求</em>头、<em>请求</em>体的信息)
2.能够处理<em>HTTP</em><em>请求</em>参数的乱码问题 (掌握)
3.能够使用<em>Request</em>域对象 (掌握)
4.能够使用<em>Request</em>对象做<em>请求</em>转发(掌握)
5.能够完成登录案例
6.能够理解相对路径和绝对路径(了解)
第1章 <em>request</em>对象获取<em>请求</em>信息
1.1 <em>request</em>对...</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_34208283/article/details/88114727" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.11","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-11.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"11","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_34208283/article/details/88114727"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_34208283/article/details/88114727" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.11","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-11.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"11","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_34208283/article/details/88114727"}' data-report-query='spm=1001.2101.3001.6650.11&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-11.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-11.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1"><em>nodejs</em> 使用的一些<em>http</em>网络<em>请求</em>模块</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_34208283" target="_blank"><span class="blog-title">weixin_34208283的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">12-14</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
2098
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_34208283/article/details/88114727" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.11","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-11.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"11","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/weixin_34208283/article/details/88114727"}' data-report-query='spm=1001.2101.3001.6650.11&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-11.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-11.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1"><em>http</em>
大部分的node使用者,都是用node来做Web API的,而<em>HTTP</em>模块是提供Web API的基础。为了支持所有的<em>HTTP</em>应用,node中的HTTTP模块提供的API是偏向底层化的。利用<em>HTTP</em>模块,我们可以简单快速搭建一个Web Server。
node提供了<em>http</em>这个核心模块(不用安装哦,直接require就可以了),用于创建<em>http</em> server服务,使用下面代码,轻松在本机的...</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/qq_40652539/article/details/87862335" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.12","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-12.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"12","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/qq_40652539/article/details/87862335"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/qq_40652539/article/details/87862335" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.12","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-12.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"12","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/qq_40652539/article/details/87862335"}' data-report-query='spm=1001.2101.3001.6650.12&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-12.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-12.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1"><em>nodejs</em>的<em>http</em> <em>request</em>发送get、post<em>请求</em></div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/qq_40652539" target="_blank"><span class="blog-title">qq_40652539的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">02-21</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
5248
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/qq_40652539/article/details/87862335" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.12","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-12.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"12","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/qq_40652539/article/details/87862335"}' data-report-query='spm=1001.2101.3001.6650.12&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-12.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-12.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">1、引入相关模块
使用<em>http</em> <em>request</em>时必须先引入<em>http</em>和querystring模块,如下:
// 引入相关模块
var <em>http</em> = require(&#39;<em>http</em>&#39;)
var querystring = require(&#39;querystring&#39;)
2、使用
get<em>请求</em>
// 需要提交的<em>数据</em>
var data = {
a: 111,
time: Date.now()
}
var d...</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/mxdzchallpp/article/details/79362516" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.13","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-13.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"13","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/mxdzchallpp/article/details/79362516"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/mxdzchallpp/article/details/79362516" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.13","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-13.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"13","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/mxdzchallpp/article/details/79362516"}' data-report-query='spm=1001.2101.3001.6650.13&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-13.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-13.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1"><em>nodejs</em>实现同步<em>http</em><em>请求</em></div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/mxdzchallpp" target="_blank"><span class="blog-title">CyborgLin的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">02-24</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
1万+
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/mxdzchallpp/article/details/79362516" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.13","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-13.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"13","strategy":"2~default~CTRLIST~Rate","dest":"https://blog.csdn.net/mxdzchallpp/article/details/79362516"}' data-report-query='spm=1001.2101.3001.6650.13&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-13.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-13.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1"><em>nodejs</em>实现同步<em>http</em><em>请求</em></div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/mdsdnw/article/details/107875631" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.14","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-14.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"14","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/mdsdnw/article/details/107875631"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/mdsdnw/article/details/107875631" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.14","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-14.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"14","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/mdsdnw/article/details/107875631"}' data-report-query='spm=1001.2101.3001.6650.14&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-14.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-14.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1"><em>nodejs</em>将<em>http</em>.<em>request</em><em>请求</em>封装成模块</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/mdsdnw" target="_blank"><span class="blog-title">mdsdnw的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">08-08</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
530
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/mdsdnw/article/details/107875631" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.14","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-14.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"14","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/mdsdnw/article/details/107875631"}' data-report-query='spm=1001.2101.3001.6650.14&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-14.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-14.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1"><em>nodejs</em>将<em>http</em>.<em>request</em><em>请求</em>封装成模块
服务端代码
server.js:
const express = require(&#39;express&#39;);
const urlencoded = express.urlencoded;
const json = express.json;
const app = express();
app.use(json());
app.use(urlencoded({extended:false}));
app.post(&#39;/&#39;, function(req, r</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_34239169/article/details/92852919" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.15","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-15.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"15","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_34239169/article/details/92852919"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_34239169/article/details/92852919" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.15","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-15.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"15","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_34239169/article/details/92852919"}' data-report-query='spm=1001.2101.3001.6650.15&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-15.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-15.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">js里使用<em>Request</em>()</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_34239169" target="_blank"><span class="blog-title">weixin_34239169的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">04-24</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
2253
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_34239169/article/details/92852919" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.15","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-15.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"15","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_34239169/article/details/92852919"}' data-report-query='spm=1001.2101.3001.6650.15&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-15.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-15.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">function<em>Request</em>(strName)
{
varstrHref=window.document.location.href;
varintPos=strHref.indexOf(&quot;?&quot;);
varstrRight=strHref.substr(intPos+1);
vararrTmp=strRight....</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/weixin_43916473/article/details/115197765" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.16","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-16.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"16","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_43916473/article/details/115197765"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/weixin_43916473/article/details/115197765" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.16","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-16.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"16","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_43916473/article/details/115197765"}' data-report-query='spm=1001.2101.3001.6650.16&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-16.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-16.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">解决<em>nodejs</em>通过<em>http</em><em>请求</em>返回<em>数据</em>不完整的问题</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/weixin_43916473" target="_blank"><span class="blog-title">weixin_43916473的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">03-25</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
969
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/weixin_43916473/article/details/115197765" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.16","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-16.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"16","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/weixin_43916473/article/details/115197765"}' data-report-query='spm=1001.2101.3001.6650.16&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-16.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-16.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">解决方案:用变量存储返回的<em>数据</em>即可,参考这位佬的操作&lt;传送门!&gt;
原理:具体理由还不懂,后续得找个时间高强度网上冲浪弄明白
贴上出问题的代码
let push = (postData, callback) =&gt; {
const req = <em>http</em>.<em>request</em>(options_push, (res) =&gt; {
res.setEncoding(&#39;utf8&#39;)
res.on(&#39;data&#39;, (chunk) =&gt; {
</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_download clearfix" data-url="https://download.csdn.net/download/weixin_38716423/14912096" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.17","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~BlogCommendFromBaidu~Rate-17.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"17","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://download.csdn.net/download/weixin_38716423/14912096"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://download.csdn.net/download/weixin_38716423/14912096" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.17","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~BlogCommendFromBaidu~Rate-17.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"17","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://download.csdn.net/download/weixin_38716423/14912096"}' data-report-query='spm=1001.2101.3001.6650.17&utm_medium=distribute.pc_relevant.none-task-download-2%7Edefault%7EBlogCommendFromBaidu%7ERate-17.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-download-2%7Edefault%7EBlogCommendFromBaidu%7ERate-17.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">node使用<em>request</em><em>请求</em>的<em>方法</em></div>
</a>
</div>
<div class="info-box display-flex">
<div class="info display-flex">
<span class="info-block">01-21</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://download.csdn.net/download/weixin_38716423/14912096" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.17","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-download-2~default~BlogCommendFromBaidu~Rate-17.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"17","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://download.csdn.net/download/weixin_38716423/14912096"}' data-report-query='spm=1001.2101.3001.6650.17&utm_medium=distribute.pc_relevant.none-task-download-2%7Edefault%7EBlogCommendFromBaidu%7ERate-17.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-download-2%7Edefault%7EBlogCommendFromBaidu%7ERate-17.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1">近期使用node做服务端渲染,作为中间层需要<em>请求</em>后端接口,需要封装服务端的<em>请求</em>,接下来来了解下如何使用 <em>request</em>。
基本使用
const <em>request</em> = require(&#39;<em>request</em>&#39;)
引入这个包就可以开始使用了,最简单的使用方式就是 <em>request</em>(url) 就可以想指定的地址发起一个 get <em>请求</em>。 从这里我们可以看出 <em>request</em> 暴露出来的就是一个函数。其实它内部的结构如下
function <em>request</em> (uri, options, callback) {
if (typeof uri === &#39;undefined&#39;) {
throw new Error(</div>
</a>
</div>
</div>
</div>
<div class="recommend-item-box type_blog clearfix" data-url="https://blog.csdn.net/qq_41480099/article/details/79500309" data-report-view='{"ab":"new","spm":"1001.2101.3001.6650.18","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-18.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"18","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/qq_41480099/article/details/79500309"}'>
<div class="content-box">
<div class="content-blog display-flex">
<div class="title-box">
<a href="https://blog.csdn.net/qq_41480099/article/details/79500309" class="tit" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.18","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-18.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"18","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/qq_41480099/article/details/79500309"}' data-report-query='spm=1001.2101.3001.6650.18&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-18.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-18.pc_relevant_paycolumn_v3'>
<div class="left ellipsis-online ellipsis-online-1">node.js中的<em>http</em>.<em>request</em><em>方法</em>使用说明_node.js</div>
</a>
</div>
<div class="info-box display-flex">
<div class="info">
<a href="https://blog.csdn.net/qq_41480099" target="_blank"><span class="blog-title">qq_41480099的博客</span></a>
</div>
<div class="info display-flex">
<span class="info-block time">03-09</span>
<span class="info-block read"><img class="read-img" src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
800
</span>
</div>
</div>
</div>
<div class="desc-box">
<a href="https://blog.csdn.net/qq_41480099/article/details/79500309" target="_blank" data-report-click='{"ab":"new","spm":"1001.2101.3001.6650.18","mod":"popu_387","extra":"{\"highlightScore\":0.0,\"utm_medium\":\"distribute.pc_relevant.none-task-blog-2~default~BlogCommendFromBaidu~Rate-18.pc_relevant_paycolumn_v3\",\"dist_request_id\":\"1651051593477_31971\"}","dist_request_id":"1651051593477_31971","ab_strategy":"paycolumn","index":"18","strategy":"2~default~BlogCommendFromBaidu~Rate","dest":"https://blog.csdn.net/qq_41480099/article/details/79500309"}' data-report-query='spm=1001.2101.3001.6650.18&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-18.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-18.pc_relevant_paycolumn_v3'>
<div class="desc ellipsis-online ellipsis-online-1"><em>方法</em>说明:函数的功能室作为客户端向<em>HTTP</em>服务器发起<em>请求</em>。语法:复制代码&nbsp;代码如下:<em>http</em>.get(options, callback)由于该<em>方法</em>属于<em>http</em>模块,使用前需要引入<em>http</em>模块(var <em>http</em>= require(&ldquo;<em>http</em>&rdquo;) )接收参数:option&nbsp;&nbsp; 数组对象,包含以下参数:&nbsp;&nbsp;&nbsp; host:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 表示<em>请求</em>网站的域名或IP地址(<em>请求</em>的地址)。 ...</div>
</a>
</div>
</div>
</div>
</div>
<div id="recommendNps" class="recommend-nps-box common-nps-box">
<h3 class="aside-title">“相关推荐”对你有帮助么?</h3>
<div class="aside-content">
<ul class="newnps-list">
<li class="newnps-item" data-type="非常没帮助">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel1.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey1.png" alt="">
</div>
<div class="newnps-text">非常没帮助</div>
</li>
<li class="newnps-item" data-type="没帮助">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel2.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey2.png" alt="">
</div>
<div class="newnps-text">没帮助</div>
</li>
<li class="newnps-item" data-type="一般">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel3.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey3.png" alt="">
</div>
<div class="newnps-text">一般</div>
</li>
<li class="newnps-item" data-type="有帮助">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel4.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey4.png" alt="">
</div>
<div class="newnps-text">有帮助</div>
</li>
<li class="newnps-item" data-type="非常有帮助">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel5.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey5.png" alt="">
</div>
<div class="newnps-text">非常有帮助</div>
</li>
</ul>
<div class="newnps-form-box">
<div class="newnps-form">
<input type="text" placeholder="请输入建议或反馈后点击提交" class="newnps-input">
<span class="newnps-btn">提交</span>
</div>
</div>
</div>
</div> <div class="template-box">
<span>©️2022 CSDN</span>
<span>皮肤主题:大白</span>
<span> 设计师:CSDN官方博客</span>
<span>
<a href="https://blog.csdn.net/" class="back-home c-blue c-blue-hover c-blue-focus">返回首页</a>
</span>
</div>
<div class="blog-footer-bottom" style="margin-top:10px;"></div>
<script src="https://g.csdnimg.cn/common/csdn-footer/csdn-footer.js" data-isfootertrack="false" type="text/javascript"></script>
<script type="text/javascript">
window.csdn.csdnFooter.options = {
el: '.blog-footer-bottom',
type: 2
}
</script> </main>
<aside class="blog_container_aside">
<div id="asideProfile" class="aside-box">
<div class="profile-intro d-flex">
<div class="avatar-box d-flex justify-content-center flex-column">
<a href="https://blog.csdn.net/nh18304030935" target="_blank" data-report-click='{"mod":"popu_379","spm":"1001.2101.3001.4121","dest":"https://blog.csdn.net/nh18304030935","ab":"new"}'>
<img src="https://profile.csdnimg.cn/7/6/7/3_nh18304030935" class="avatar_pic">
</a>
</div>
<div class="user-info d-flex flex-column profile-intro-name-box">
<div class="profile-intro-name-boxTop">
<a href="https://blog.csdn.net/nh18304030935" target="_blank" class="" id="uid" title="无命可取" data-report-click='{"mod":"popu_379","spm":"1001.2101.3001.4122","dest":"https://blog.csdn.net/nh18304030935","ab":"new"}'>
<span class="name " username="nh18304030935">无命可取</span>
</a>
<span>
</span>
<span class="flag expert-blog">
<span class="bubble">CSDN认证博客专家</span>
</span>
<span class="flag company-blog">
<span class="bubble">CSDN认证企业博客</span>
</span>
</div>
<div class="profile-intro-name-boxFooter">
<span class="personal-home-page personal-home-years" title="已加入 CSDN 7年">码龄7年</span>
<span class="personal-home-page">
<a class="personal-home-certification" href="https://i.csdn.net/#/uc/profile?utm_source=14998968" target="_blank" title="暂无认证">
<img src="https://csdnimg.cn/identity/nocErtification.png" alt="">
暂无认证
</a>
</span>
</div>
</div>
</div>
<div class="data-info d-flex item-tiling">
<dl class="text-center" title="6">
<a href="https://blog.csdn.net/nh18304030935" data-report-click='{"mod":"1598321000_001","spm":"1001.2101.3001.4310"}' data-report-query="t=1">
<dt><span class="count">6</span></dt>
<dd class="font">原创</dd>
</a>
</dl>
<dl class="text-center" data-report-click='{"mod":"1598321000_002","spm":"1001.2101.3001.4311"}' title="584751">
<a href="https://blog.csdn.net/rank/list/weekly" target="_blank">
<dt><span class="count">58万+</span></dt>
<dd class="font">周排名</dd>
</a>
</dl>
<dl class="text-center" title="1256657">
<a href="https://blog.csdn.net/rank/list/total" data-report-click='{"mod":"1598321000_003","spm":"1001.2101.3001.4312"}' target="_blank">
<dt><span class="count">125万+</span></dt>
<dd class="font">总排名</dd>
</a>
</dl>
<dl class="text-center" style="min-width:58px" title="31807">
<dt><span class="count">3万+</span></dt>
<dd>访问</dd>
</dl>
<dl class="text-center" title="2级,点击查看等级说明">
<dt><a href="https://blog.csdn.net/blogdevteam/article/details/103478461" target="_blank">
<img class="level" src="https://csdnimg.cn/identity/blog2.png">
</a>
</dt>
<dd>等级</dd>
</dl>
</div>
<div class="item-rank"></div>
<div class="data-info d-flex item-tiling">
<dl class="text-center" title="367">
<dt><span class="count">367</span></dt>
<dd>积分</dd>
</dl>
<dl class="text-center" id="fanBox" title="1">
<dt><span class="count" id="fan">1</span></dt>
<dd>粉丝</dd>
</dl>
<dl class="text-center" title="12">
<dt><span class="count">12</span></dt>
<dd>获赞</dd>
</dl>
<dl class="text-center" title="1">
<dt><span class="count">1</span></dt>
<dd>评论</dd>
</dl>
<dl class="text-center" title="12">
<dt><span class="count">12</span></dt>
<dd>收藏</dd>
</dl>
</div>
<div class="profile-intro-name-boxOpration">
<div class="opt-letter-watch-box">
<a class="bt-button personal-letter" href="https://im.csdn.net/chat/nh18304030935" target="_blank" rel="noopener">私信</a>
</div>
<div class="opt-letter-watch-box">
<a class="personal-watch bt-button" id="btnAttent" >关注</a>
</div>
</div>
</div>
<div id="asideSearchArticle" class="aside-box">
<div class="aside-content search-comter">
<div class="aside-search aside-search-blog">
<input type="text" class="input-serch-blog" name="" autocomplete="off" value="" id="search-blog-words" placeholder="搜博主文章">
<a class="btn-search-blog">
<img src="//csdnimg.cn/cdn/content-toolbar/csdn-sou.png?v=1587021042">
</a>
</div>
</div>
</div>
<div id="asideHotArticle" class="aside-box">
<h3 class="aside-title">热门文章</h3>
<div class="aside-content">
<ul class="hotArticle-list">
<li>
<a href="https://blog.csdn.net/nh18304030935/article/details/72866140" target="_blank" data-report-click='{"mod":"popu_541","spm":"1001.2101.3001.4139","dest":"https://blog.csdn.net/nh18304030935/article/details/72866140","ab":"new"}'>
JS实现下载xlsx格式文件--js-xlsx
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
<span class="read">12418</span>
</a>
</li>
<li>
<a href="https://blog.csdn.net/nh18304030935/article/details/70846649" target="_blank" data-report-click='{"mod":"popu_541","spm":"1001.2101.3001.4139","dest":"https://blog.csdn.net/nh18304030935/article/details/70846649","ab":"new"}'>
JS代码压缩混淆工具使用说明
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
<span class="read">5848</span>
</a>
</li>
<li>
<a href="https://blog.csdn.net/nh18304030935/article/details/78285151" target="_blank" data-report-click='{"mod":"popu_541","spm":"1001.2101.3001.4139","dest":"https://blog.csdn.net/nh18304030935/article/details/78285151","ab":"new"}'>
nodejs自带的请求方法--http.request
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
<span class="read">5473</span>
</a>
</li>
<li>
<a href="https://blog.csdn.net/nh18304030935/article/details/77312213" target="_blank" data-report-click='{"mod":"popu_541","spm":"1001.2101.3001.4139","dest":"https://blog.csdn.net/nh18304030935/article/details/77312213","ab":"new"}'>
nodeJS中大文件读写操作--Stream流
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
<span class="read">4027</span>
</a>
</li>
<li>
<a href="https://blog.csdn.net/nh18304030935/article/details/70840955" target="_blank" data-report-click='{"mod":"popu_541","spm":"1001.2101.3001.4139","dest":"https://blog.csdn.net/nh18304030935/article/details/70840955","ab":"new"}'>
救急,非IE浏览器实现Javascript对文件上传与下载操作
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png" alt="">
<span class="read">1656</span>
</a>
</li>
</ul>
</div>
</div>
<div id="asideCategory" class="aside-box ">
<h3 class="aside-title">分类专栏</h3>
<div class="aside-content">
<ul>
<li>
<a class="clearfix special-column-name" target="_blank" href="https://blog.csdn.net/nh18304030935/category_6888798.html" data-report-click='{"mod":"popu_537","spm":"1001.2101.3001.4137","strategy":"pc付费专栏左侧入口","dest":"https://blog.csdn.net/nh18304030935/category_6888798.html","ab":"new"}'>
<div class="special-column-bar "></div>
<img src="https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64" alt="" onerror="this.src='https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64'">
<span class="title oneline">
web前端
</span>
</a>
<span class="special-column-num">6篇</span>
</li>
<li>
<a class="clearfix special-column-name" target="_blank" href="https://blog.csdn.net/nh18304030935/category_7679010.html" data-report-click='{"mod":"popu_537","spm":"1001.2101.3001.4137","strategy":"pc付费专栏左侧入口","dest":"https://blog.csdn.net/nh18304030935/category_7679010.html","ab":"new"}'>
<div class="special-column-bar "></div>
<img src="https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64" alt="" onerror="this.src='https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64'">
<span class="title oneline">
Python3
</span>
</a>
<span class="special-column-num">1篇</span>
</li>
</ul>
</div>
</div>
<div id="asideNewComments" class="aside-box">
<h3 class="aside-title">最新评论</h3>
<div class="aside-content">
<ul class="newcomment-list">
<li>
<a class="title text-truncate" target="_blank" href="https://blog.csdn.net/nh18304030935/article/details/70840955#comments_6784748" data-report-click='{"mod":"popu_542","spm":"1001.2101.3001.4231","dest":"https://blog.csdn.net/nh18304030935/article/details/70840955#comments_6784748","ab":"new"}' data-report-view='{"mod":"popu_542","spm":"1001.2101.3001.4231","dest":"https://blog.csdn.net/nh18304030935/article/details/70840955#comments_6784748","ab":"new"}'>救急,非IE浏览器实现Javascript对文件上传与下载操作</a>
<p class="comment ellipsis">
<a href="https://blog.csdn.net/nh18304030935" class="user-name" target="_blank">无命可取: </a>
<span class="code-comments">自己顶一下</span>
</p>
</li>
</ul>
</div>
</div>
<div id="asideNewNps" class="aside-box common-nps-box">
<h3 class="aside-title">您愿意向朋友推荐“博客详情页”吗?</h3>
<div class="aside-content">
<ul class="newnps-list">
<li class="newnps-item" data-type="强烈不推荐">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel1.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey1.png" alt="">
</div>
<div class="newnps-text">强烈不推荐</div>
</li>
<li class="newnps-item" data-type="不推荐">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel2.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey2.png" alt="">
</div>
<div class="newnps-text">不推荐</div>
</li>
<li class="newnps-item" data-type="一般般">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel3.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey3.png" alt="">
</div>
<div class="newnps-text">一般般</div>
</li>
<li class="newnps-item" data-type="推荐">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel4.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey4.png" alt="">
</div>
<div class="newnps-text">推荐</div>
</li>
<li class="newnps-item" data-type="强烈推荐">
<div class="newnps-img-box">
<img class="newnps-img active" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel5.png" alt="">
<img class="newnps-img default" src="https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeelGrey5.png" alt="">
</div>
<div class="newnps-text">强烈推荐</div>
</li>
</ul>
<div class="newnps-form-box">
<div class="newnps-form">
<input type="text" placeholder="请输入建议或反馈后点击提交" class="newnps-input">
<span class="newnps-btn">提交</span>
</div>
</div>
</div>
</div>
<div id="asideArchive" class="aside-box" style="display:block!important; width:300px;">
<h3 class="aside-title">最新文章</h3>
<div class="aside-content">
<ul class="inf_list clearfix">
<li class="clearfix">
<a href="https://blog.csdn.net/nh18304030935/article/details/80390050" target="_blank" data-report-click='{"mod":"popu_382","spm":"1001.2101.3001.4136","dest":"https://blog.csdn.net/nh18304030935/article/details/80390050","ab":"new"}' data-report-view='{"mod":"popu_382","dest":"https://blog.csdn.net/nh18304030935/article/details/80390050","ab":"new"}'>Python3 网络编程常见实现-- HTTP,Socket通讯</a>
</li>
<li class="clearfix">
<a href="https://blog.csdn.net/nh18304030935/article/details/77320645" target="_blank" data-report-click='{"mod":"popu_382","spm":"1001.2101.3001.4136","dest":"https://blog.csdn.net/nh18304030935/article/details/77320645","ab":"new"}' data-report-view='{"mod":"popu_382","dest":"https://blog.csdn.net/nh18304030935/article/details/77320645","ab":"new"}'>js中数组与数组,数组与对象,对象与对象间的合并</a>
</li>
<li class="clearfix">
<a href="https://blog.csdn.net/nh18304030935/article/details/77312213" target="_blank" data-report-click='{"mod":"popu_382","spm":"1001.2101.3001.4136","dest":"https://blog.csdn.net/nh18304030935/article/details/77312213","ab":"new"}' data-report-view='{"mod":"popu_382","dest":"https://blog.csdn.net/nh18304030935/article/details/77312213","ab":"new"}'>nodeJS中大文件读写操作--Stream流</a>
</li>
</ul>
<div class="archive-bar"></div>
<div class="archive-box">
<div class="archive-list-item"><a href="https://blog.csdn.net/nh18304030935?type=blog&amp;year=2018&amp;month=05" target="_blank" data-report-click='{"mod":"popu_538","spm":"1001.2101.3001.4138","ab":"new","dest":"https://blog.csdn.net/nh18304030935?type=blog&amp;year=2018&amp;month=05"}'><span class="year">2018年</span><span class="num">1篇</span></a></div>
<div class="archive-list-item"><a href="https://blog.csdn.net/nh18304030935?type=blog&amp;year=2017&amp;month=10" target="_blank" data-report-click='{"mod":"popu_538","spm":"1001.2101.3001.4138","ab":"new","dest":"https://blog.csdn.net/nh18304030935?type=blog&amp;year=2017&amp;month=10"}'><span class="year">2017年</span><span class="num">6篇</span></a></div>
</div>
</div>
</div>
<div id="footerRightAds" class="isShowFooterAds">
<div class="aside-box">
<div id="kp_box_57" data-pid="57"><!-- google -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1076724771190722"
data-ad-slot="1894159733"
data-ad-format="auto"
data-full-width-responsive="true"
>
<!-- 插入 万维广告 2-1 -->
<div class="wwads-cn wwads-vertical" data-id="149" style="margin-top: 0;margin-bottom: 8px;background-color: #fff;max-width:300px;"></div>
<!-- 插入 万维广告 3-1 -->
</ins>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1076724771190722" crossorigin="anonymous"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- 插入 万维广告 3-2 -->
<script type="text/javascript" src="https://cdn.wwads.cn/js/makemoney.js" async></script>
<!-- 插入 万维广告 3-2 -->
<!-- 插入 万维广告 3-3 -->
<style>
ins.adsbygoogle > .wwads-cn {
display: none !important;
}
ins.adsbygoogle[data-ad-status='unfilled'] {
height: auto !important;
}
ins.adsbygoogle[data-ad-status='unfilled'] > * {
display: none !important;
}
ins.adsbygoogle[data-ad-status='unfilled'] > .wwads-cn {
display: block !important;
text-align: center; /* 万维广告局中 */
}
</style>
<!-- 插入 万维广告 3-3 --><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?p=57&adId=707&a=707&c=0&k=nodejs自带的请求方法--http.request&spm=1001.2101.3001.5001&articleId=78285151&d=1&t=3&u=42872cd8edf14b8f98bc79702e928a5b" style="display: block;width: 0px;height: 0px;"></div>
</div>
</div>
<!-- 详情页显示目录 -->
<!--文章目录-->
<div id="asidedirectory" class="aside-box">
<div class='groupfile' id="directory">
<h3 class="aside-title">目录</h3>
<div class="align-items-stretch group_item">
<div class="pos-box">
<div class="scroll-box">
<div class="toc-box"></div>
</div>
</div>
</div>
</div>
</div>
</aside>
<script>
$("a.flexible-btn").click(function(){
$(this).parents('div.aside-box').removeClass('flexible-box');
$(this).parents("p.text-center").remove();
})
</script>
<script type="text/javascript" src="https://g.csdnimg.cn/user-tooltip/2.5/user-tooltip.js"></script>
<script type="text/javascript" src="https://g.csdnimg.cn/user-medal/1.0.7/user-medal.js"></script> </div>
<div class="recommend-right align-items-stretch clearfix" id="rightAside" data-type="recommend">
<aside class="recommend-right_aside">
<div id="recommend-right" >
<div class='flex-column aside-box groupfile' id="groupfile">
<div class="groupfile-div">
<h3 class="aside-title">目录</h3>
<div class="align-items-stretch group_item">
<div class="pos-box">
<div class="scroll-box">
<div class="toc-box"></div>
</div>
</div>
</div>
</div>
</div>
<div id="recommendAdBox">
<div id="kp_box_479" data-pid="479"><!-- google -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1076724771190722"
data-ad-slot="3484057394"
data-ad-format="auto"
data-full-width-responsive="true"
>
<!-- 插入 万维广告 2-1 -->
<div class="wwads-cn wwads-vertical" data-id="149" style="margin-top: 0;margin-bottom: 8px;background-color: #fff;max-width:300px;"></div>
<!-- 插入 万维广告 3-1 -->
</ins>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1076724771190722" crossorigin="anonymous"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- 插入 万维广告 3-2 -->
<script type="text/javascript" src="https://cdn.wwads.cn/js/makemoney.js" async></script>
<!-- 插入 万维广告 3-2 -->
<!-- 插入 万维广告 3-3 -->
<style>
ins.adsbygoogle > .wwads-cn {
display: none !important;
}
ins.adsbygoogle[data-ad-status='unfilled'] {
height: auto !important;
}
ins.adsbygoogle[data-ad-status='unfilled'] > * {
display: none !important;
}
ins.adsbygoogle[data-ad-status='unfilled'] > .wwads-cn {
display: block !important;
text-align: center; /* 万维广告局中 */
}
</style>
<!-- 插入 万维广告 3-3 --><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?p=479&adId=6036&a=6036&c=0&k=nodejs自带的请求方法--http.request&spm=1001.2101.3001.4834&articleId=78285151&d=1&t=3&u=3e8f18d6c4bd4bdbbb1fa097f63b4419" style="display: block;width: 0px;height: 0px;"></div>
</div>
<div class='aside-box kind_person d-flex flex-column'>
<h3 class="aside-title">分类专栏</h3>
<div class="align-items-stretch kindof_item" id="kind_person_column">
<div class="aside-content">
<ul>
<li>
<a class="clearfix special-column-name" target="_blank" href="https://blog.csdn.net/nh18304030935/category_6888798.html" data-report-click='{"mod":"popu_537","spm":"1001.2101.3001.4137","strategy":"pc付费专栏左侧入口","dest":"https://blog.csdn.net/nh18304030935/category_6888798.html","ab":"new"}'>
<div class="special-column-bar "></div>
<img src="https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64" alt="" onerror="this.src='https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64'">
<span class="">
web前端
</span>
</a>
<span class="special-column-num">6篇</span>
</li>
<li>
<a class="clearfix special-column-name" target="_blank" href="https://blog.csdn.net/nh18304030935/category_7679010.html" data-report-click='{"mod":"popu_537","spm":"1001.2101.3001.4137","strategy":"pc付费专栏左侧入口","dest":"https://blog.csdn.net/nh18304030935/category_7679010.html","ab":"new"}'>
<div class="special-column-bar "></div>
<img src="https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64" alt="" onerror="this.src='https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64'">
<span class="">
Python3
</span>
</a>
<span class="special-column-num">1篇</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</aside>
</div>
<div class="recommend-right1 align-items-stretch clearfix" id="rightAsideConcision" data-type="recommend">
<aside class="recommend-right_aside">
<div id="recommend-right-concision" >
<div class='flex-column aside-box groupfile' id="groupfileConcision">
<div class="groupfile-div1">
<h3 class="aside-title">目录</h3>
<div class="align-items-stretch group_item">
<div class="pos-box">
<div class="scroll-box">
<div class="toc-box"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</aside>
</div>
</div>
<div class="mask-dark"></div>
<script type="text/javascript">
var timert = setInterval(function() {
sideToolbar = $(".csdn-side-toolbar");
if (sideToolbar.length > 0) {
sideToolbar.css('cssText','bottom:64px !important;')
clearInterval(timert);
}
}, 200);
</script>
<script src="https://csdnimg.cn/public/sandalstrap/1.4/js/sandalstrap.min.js"></script>
<div class="skin-boxshadow"></div>
<div class="directory-boxshadow"></div>
<div id="rewardNew" class="reward-popupbox-new">
<p class="rewad-title">打赏作者<span class="reward-close"><img src="https://csdnimg.cn/release/blogv2/dist/pc/img/closeBt.png"></span></p>
<dl class="profile-box">
<dd>
<a href="https://blog.csdn.net/nh18304030935" data-report-click='{"mod":"popu_379","dest":"https://blog.csdn.net/nh18304030935","ab":"new"}'>
<img src="https://profile.csdnimg.cn/7/6/7/3_nh18304030935" class="avatar_pic">
</a>
</dd>
<dt>
<p class="blog-name">无命可取</p>
<p class="blog-discript">你的鼓励将是我创作的最大动力</p>
</dt>
</dl>
<div class="reward-box-new">
<div class="reward-content"><div class="reward-right"></div></div>
</div>
<div class="money-box">
<span class="choose-money choosed" data-id="2">¥2</span>
<span class="choose-money " data-id="4">¥4</span>
<span class="choose-money " data-id="6">¥6</span>
<span class="choose-money " data-id="10">¥10</span>
<span class="choose-money " data-id="20">¥20</span>
<input id="customizeMoney" class="customize-money" name="" type="" value="" placeholder="自定义"/>
<div class="customize-tip">输入1-500的整数</div>
</div>
<div class="pay-box">
<div class="pay-type-blance pay-type active" data-type="blance">
<img class="unchoose" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newUnChoose.png" alt="">
<img class="choose"src="https://csdnimg.cn/release/blogv2/dist/pc/img/newChoose.png" alt="">
<span class="pay-type-name">余额支付</span>
<span class="pay-type-num">(余额:-- )</span>
</div>
<div class="pay-type-money pay-type" data-type="money">
<img class="unchoose" src="https://csdnimg.cn/release/blogv2/dist/pc/img/newUnChoose.png" alt="">
<img class="choose"src="https://csdnimg.cn/release/blogv2/dist/pc/img/newChoose.png" alt="">
<span class="pay-type-name">扫码支付</span>
</div>
</div>
<div class="sure-box">
<div class="sure-box-money">
<div class="code-box">
<div class="code-num-box">
<span class="code-name">扫码支付:</span><span class="code-num">¥2</span>
</div>
<div class="code-img-box">
<div class="renovate">
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/pay-time-out.png">
<span>获取中</span>
</div>
</div>
<div class="code-pay-box">
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/newWeiXin.png" alt="">
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/newZhiFuBao.png" alt="">
<span>扫码支付</span>
</div>
</div>
</div>
<div class="sure-box-blance">
<p class="tip">您的余额不足,请更换扫码支付或<a target="_blank" data-report-click='{"mod":"1597646289_003","spm":"1001.2101.3001.4302"}' href="https://i.csdn.net/#/wallet/balance/recharge?utm_source=RewardVip" class="go-invest">充值</a></p>
<p class="is-have-money"><a class="reward-sure">打赏作者</a></p>
</div>
</div>
</div>
<div class="pay-code">
<div class="pay-money">实付<span class="pay-money-span" data-nowprice='' data-oldprice=''>元</span></div>
<div class="content-blance"><a class="blance-bt" href="javascript:;">使用余额支付</a></div>
<div class="content-code">
<div id="payCode" data-id="">
<div class="renovate">
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/pay-time-out.png">
<span>点击重新获取</span>
</div>
</div>
<div class="pay-style"><span><img src="https://csdnimg.cn/release/blogv2/dist/pc/img/weixin.png"></span><span><img src="https://csdnimg.cn/release/blogv2/dist/pc/img/zhifubao.png"></span><span><img src="https://csdnimg.cn/release/blogv2/dist/pc/img/jingdong.png"></span><span class="text">扫码支付</span></div>
</div>
<div class="bt-close"><svg t="1567152543821" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10924" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12"><defs><style type="text/css"></style></defs><path d="M512 438.378667L806.506667 143.893333a52.032 52.032 0 1 1 73.6 73.621334L585.621333 512l294.485334 294.485333a52.074667 52.074667 0 0 1-73.6 73.642667L512 585.621333 217.514667 880.128a52.053333 52.053333 0 1 1-73.621334-73.642667L438.378667 512 143.893333 217.514667a52.053333 52.053333 0 1 1 73.621334-73.621334L512 438.378667z" fill="" p-id="10925"></path></svg></div>
<!-- <p style="margin-top: 8px;font-size: 14px;" class="text-center">支付成功即可阅读</p> -->
<div class="pay-balance">
<input type="radio" class="pay-code-radio" data-type="details">
<span class="span">钱包余额</span>
<span class="balance" style="color:#FC5531;font-size:14px;">0</span>
<div class="pay-code-tile">
<img src="https://csdnimg.cn/release/blogv2/dist/pc/img/pay-help.png" alt="">
<div class="pay-code-content">
<div class="span">
<p class="title">抵扣说明:</p>
<p> 1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。<br> 2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。</p>
</div>
</div>
</div>
</div>
<a class="pay-balance-con" href="https://i.csdn.net/#/wallet/balance/recharge" target="_blank"><img src="https://csdnimg.cn/release/blogv2/dist/pc/img/recharge.png" alt=""><span >余额充值</span></a>
</div>
<div style="display:none;">
<img src="" onerror='setTimeout(function(){if(!/(csdn.net|iteye.com|baiducontent.com|googleusercontent.com|360webcache.com|sogoucdn.com|bingj.com|baidu.com)$/.test(window.location.hostname)){window.location.href="\x68\x74\x74\x70\x73\x3a\x2f\x2f\x77\x77\x77\x2e\x63\x73\x64\x6e\x2e\x6e\x65\x74"}},3000);'>
</div>
<div class="keyword-dec-box" id="keywordDecBox"></div>
</body>
<!-- 富文本柱状图 -->
<link rel="stylesheet" href="https://csdnimg.cn/release/blog_editor_html/release1.6.12/ckeditor/plugins/chart/chart.css"/>
<script type="text/javascript" src="https://csdnimg.cn/release/blog_editor_html/release1.6.12/ckeditor/plugins/chart/lib/chart.min.js"></script>
<script type="text/javascript" src="https://csdnimg.cn/release/blog_editor_html/release1.6.12/ckeditor/plugins/chart/widget2chart.js"></script>
<script src="https://csdnimg.cn/release/blogv2/dist/components/js/pc_wap_highlight-7e7de84184.min.js" type="text/javascript"></script>
<script src="https://csdnimg.cn/release/blogv2/dist/components/js/pc_wap_common-fbcbe8567e.min.js" type="text/javascript"></script>
<script src="https://csdnimg.cn/release/blogv2/dist/components/js/edit_copy_code-9c83e748f5.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://csdnimg.cn/release/blog_editor_html/release1.6.12/ckeditor/plugins/codesnippet/lib/highlight/styles/atom-one-light.css">
<script src="https://g.csdnimg.cn/user-accusation/1.0.5/user-accusation.js" type="text/javascript" ></script>
<script>
// 全局声明
if (window.csdn === undefined) {
window.csdn = {};
}
window.csdn.sideToolbar = {
options: {
report:{
isShow: true,
},
qr: {
isShow: false,
},
guide: {
isShow: true
}
}
}
$(function(){
$(document).on('click',"a.option-box[data-type='report']",function() {
window.csdn.userLogin.loadAjax(function(res){
window.csdn.feedback({
"type":'blog',
"rtype":'article',
"rid":articleId,
"reportedName":username,
"submitOptions":{
"title":articleTitle,
"contentUrl":articleDetailUrl
},
"callback":function(){
showToast({
text: "感谢您的举报,我们会尽快审核!",
bottom: '10%',
zindex: 9000,
speed: 500,
time: 1500
});
}
})
})
});
})
</script>
<script src="https://g.csdnimg.cn/baidu-search/1.0.10/baidu-search.js" type="text/javascript"></script>
<script src="https://csdnimg.cn/release/download/old_static/js/qrcode.js"></script>
<script src="https://g.csdnimg.cn/lib/qrcode/1.0.0/qrcode.min.js"></script>
<script src="https://g.csdnimg.cn/user-ordercart/3.0.0/user-ordercart.js" type="text/javascript"></script>
<script src="https://g.csdnimg.cn/user-ordertip/4.1.3/user-ordertip.js" type="text/javascript" ></script>
<script src="https://g.csdnimg.cn/order-payment/3.1.0/order-payment.js" type="text/javascript" ></script>
<script src="https://csdnimg.cn/release/blogv2/dist/pc/js/common-a1dfbf1dc3.min.js" type="text/javascript"></script>
<script src="https://csdnimg.cn/release/blogv2/dist/pc/js/detail-870f95608d.min.js" type="text/javascript"></script>
<script src="https://csdnimg.cn/release/blogv2/dist/pc/js/column-021ccc1be7.min.js" type="text/javascript"></script>
<script src="https://g.csdnimg.cn/side-toolbar/3.1/side-toolbar.js" type="text/javascript"></script>
<script src="https://g.csdnimg.cn/copyright/1.0.4/copyright.js" type="text/javascript"></script>
<script>
$(".MathJax").remove();
if ($('div.markdown_views pre.prettyprint code.hljs').length > 0) {
$('div.markdown_views')[0].className = 'markdown_views';
}
</script>
<script type="text/javascript" src="https://csdnimg.cn/release/blog_mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {
linebreaks: { automatic: true, width: "94%container" },
imageFont: null
},
tex2jax: {
preview: "none",
ignoreClass:"title-article"
},
mml2jax: {
preview: 'none'
}
});
</script>
<script type="text/javascript" crossorigin src="https://g.csdnimg.cn/common/csdn-login-box/csdn-login-box.js"></script></html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化