HTTP网络编程(客户端)

HTTP协议

浏览器访问过程
  • 改文章参考相关链接:https://blog.csdn.net/m_buddy/article/details/77800998

HTTP网络编程(客户端)_第1张图片

总结起来大概的流程是这样的:

  • 浏览器本身是一个客户端,当你输入URL的时候,首先浏览器会去请求DNS服务器,通过DNS获取相应的域名对应的IP

  • 然后通过IP地址找到IP对应的服务器后,要求建立TCP连接

  • 浏览器发送完HTTP Request(请求)包后,服务器接收到请求包之后才开始处理请求包

  • 在服务器收到请求之后,服务器调用自身服务,返回HTTP Response**(响应)包**

  • 客户端收到来自服务器的响应后开始渲染这个Response包里的主体(body),等收到全部的内容随后断开与该服务器之间的TCP连接。

域名解析的过程

在浏览器输入一串域名要访问某网站的时候,浏览器帮我们做了如下事情(以Chrome浏览器和windows系统为例):

  • Chrome浏览器首先检查自己本地是缓存是否有对应的域名,有则直接使用。【查看Chrome浏览器dns缓存地址:chrome://net-internals/#dns】

  • 如果浏览器缓存中没有,则查询系统DNS缓存中的域名表,有则直接使用。【windows查看域名表的命令:ipconfig /displaydns】

  • 系统缓存中还是没有,则检查hosts文件中的映射表。【windows中hosts文件路径:C:\Windows\System32\drivers\etc】

  • 本地实在找不到,则向DNS域名服务器发起请求查询。【DNS服务器IP是本地配置的首选服务器,一般常用的有114.114.114.114(电信运营商提供)和8.8.8.8(Google提供)】

    • DNS服务器首先查找自身的缓存,有对应的域名ip则返回结果
    • 如果缓存中查找不到,DNS服务器则发起迭代DNS请求,首先向根域服务器发起请求查询,假如本次请求的是www.baidu.com,根域服务器发现这是一个com的顶级域名,就把com域的ip地址返回给DNS服务器
    • DNS服务器向com域ip地址发起请求,查询该域名的ip,此时该服务器返回了baidu.com的DNS地址。
    • 最后DNS服务器又向baidu.com的DNS地址发起查询请求,最后找到了完整的ip路径返回给DNS服务器,DNS再把ip信息返回给windows内核,内核再返回给浏览器,于是浏览器就知道该域名对应的ip地址了,可以开始进一步请求了。
HTTP请求

连接成功建立后,开始向web服务器发送请求,当浏览器向Web服务器发出请求时,它向服务器传递了一个数据块,也就是请求信息,HTTP请求信息由3部分组成:

  1. 起始行:HTTP请求方法 URL HTTP版本
  2. 请求头:请求头的形式通过一个键值对进行渲染
  3. 请求体:get方法的请求体是没有内容的(放在了url里) post方法的请求体包含请求的内容

下面是一个HTTP请求的例子:

GET /sample.jsp HTTP/1.1
Accept:image/gif.image/jpeg,*/*
Accept-Language:zh-cn
Connection:Keep-Alive
Host:localhost
User-Agent:Mozila/4.0(compatible;MSIE5.01;Window NT5.0)
Accept-Encoding:gzip,deflate 
username=jinqiao&password=123412345678

起始行

  • 请求的起始行是:”方法 URL http版本GET /sample.jsp HTTP/1.1

  • 根据HTTP标准,HTTP请求可以使用多种请求方法。例如:HTTP1.1支持7种请求方法:GET、POST、HEAD、OPTIONS、PUT、DELETE和TARCE。在Internet应用中,最常用的方法是GET和POST。

  • URL完整地指定了要访问的网络资源,通常只要给出相对于服务器的根目录的相对目录即可,因此总是以“/”开头。

  • 协议版本声明了通信过程中使用HTTP的版本。

请求头(Request Header)

请求头包含许多有关的客户端环境和请求正文的有用信息。例如,请求头可以声明浏览器所用的语言,请求正文的长度等。

Accept:image/gif.image/jpeg.*/*
Accept-Language:zh-cn
Connection:Keep-Alive
Host:localhost
User-Agent:Mozila/4.0(compatible:MSIE5.01:Windows NT5.0)
Accept-Encoding:gzip,deflate.123456
  • host表示主机名,User-Agent表示用户代理即浏览器

请求正文

请求头和请求正文之间是一个空行,这个行非常重要,它表示请求头已经结束,接下来的是请求正文。请求正文中可以包含客户提交的查询字符串信息:

username=jinqiao&password=12341

在以上的例子的HTTP请求中,请求的正文只有一行内容。当然,在实际应用中,HTTP请求正文可以包含更多的内容。

HTTP响应

应答 web服务器收到这个请求,进行处理。从它的文档空间中搜索子目录mydir的文件index.html。如果找到该文件,Web服务器把该文件内容传送给相应的Web浏览器。为了告知浏览器,Web服务器首先传送一些HTTP头信息,然后传送具体内容(即HTTP体信息),HTTP头信息和HTTP体信息之间用一个空行分开。

HTTP应答与HTTP请求相似,HTTP响应也由3个部分构成,分别是:

  1. 起始行:HTTP协议版本 响应状态码 响应状态信息
  2. 响应头(Response Header) :通过键值对的形式进行表示
  3. 响应体: 网页代码 HTML、CSS、JS代码文件

下面是一个HTTP响应的例子:

HTTP/1.1 200 OK
Server:Apache Tomcat/5.0.12
Date:Mon,6Oct2003 13:23:42 GMT
Content-Length:112


    
        HTTP响应示例<title>
    </head>
    <body>
        Hello HTTP!
    </body>
</html>
</code></pre> 
  <p>协议状态代码描述HTTP响应的第一行类似于HTTP请求的第一行,它表示通信所用的协议是HTTP1.1服务器已经成功的处理了客户端发出的请求(200表示成功):<br> <code>HTTP/1.1 200 OK</code><br> 响应头(Response Header)响应头也和请求头一样包含许多有用的信息,例如服务器类型、日期时间、内容类型和长度等:</p> 
  <pre><code class="prism language-http">Server:Apache Tomcat/5.0.12
Date:Mon,6Oct2003 13:13:33 GMT
Content-Type:text/html
Last-Moified:Mon,6 Oct 2003 13:23:42 GMT
Content-Length:11212345
</code></pre> 
  <p>响应体就是服务器返回的HTML页面:</p> 
  <pre><code class="prism language-http"><html>
    <head>
        <title>HTTP响应示例<title>
    </head>
    <body>
        Hello HTTP!
    </body>
</html>12345678
</code></pre> 
  <p>响应头和正文之间也必须用<strong>空行</strong>分隔。</p> 
  <p><strong>HTTP应答码</strong></p> 
  <p><a href="http://img.e-com-net.com/image/info8/430fa7bc2bd24ea4b2dd021741c5dea7.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/430fa7bc2bd24ea4b2dd021741c5dea7.jpg" alt="HTTP网络编程(客户端)_第2张图片" width="650" height="457" style="border:1px solid black;"></a></p> 
  <p>HTTP应答码也称为状态码,它反映了Web服务器处理HTTP请求状态。<strong>HTTP应答码由3位数字构成,其中首位数字定义了应答码的类型</strong>:</p> 
  <ul> 
   <li> <p>1XX-信息类(Information),表示收到Web浏览器请求,正在进一步的处理中</p> </li> 
   <li> <p>2XX-成功类(Successful),表示用户请求被正确接收,理解和处理例如:200 OK</p> </li> 
   <li> <p>3XX - 重定向类(Redirection),表示请求没有成功,客户必须采取进一步的动作。</p> </li> 
   <li> <p>4XX - 客户端错误(Client Error),表示客户端提交的请求有错误 例如:404 NOT Found,意味着请求中所引用的文档不存在。</p> </li> 
   <li> <p>5XX - 服务器错误(Server Error)表示服务器不能完成对请求的处理:如 500</p> </li> 
  </ul> 
  <h5>任务要求:了解 HTTP 协议</h5> 
  <p>要求:</p> 
  <ul> 
   <li>HTTP 协议相关的知识主要包括: 
    <ul> 
     <li>HTTP 命令,包括:GET、POST等</li> 
     <li>HTTP 报文,包括:请求报文头,请求报文体、响应报文头和响应报文体</li> 
     <li>HTTP 响应状态码</li> 
    </ul> </li> 
   <li>阅读 HTTP 协议资料 阅读 HTTP 协议入门 阅读 HTTP 头部字段资料 阅读 HTTP 状态码资料</li> 
   <li>用 telnet 工具了解 HTTP 协议的相关知识、用 curl 工具了解 HTTP 协议的相关知识、用 chrome 开发者工具了解 HTTP 协议的相关知识</li> 
   <li>用上面三个工具访问 http://sample.wangding.in/web/one-div.html ,查看请求和响应的头信息</li> 
   <li>搞明白请求头部字段列表中每个字段的含义和作用</li> 
   <li>搞明白响应头部字段列表中每个字段的含义和作用</li> 
  </ul> 
  <pre><code class="prism language-bash">~ » <span class="token function">curl</span> http://sample.wangding.in/web/one-div.html              wangding@OFFICE
<span class="token comment"># 直接返回对应的html文件内容,由于是命令行工具,因此不能够进行渲染</span>
<span class="token operator"><</span><span class="token operator">!</span>DOCTYPE html<span class="token operator">></span>
<span class="token operator"><</span>html<span class="token operator">></span>
  <span class="token operator"><</span>head<span class="token operator">></span><span class="token operator"><</span>/head<span class="token operator">></span>
  <span class="token operator"><</span>body<span class="token operator">></span><span class="token operator"><</span>/body<span class="token operator">></span>
<span class="token operator"><</span>/html<span class="token operator">></span>
------------------------------------------------------------
~ » <span class="token function">curl</span> http://sample.wangding.in/web/one-div.html -v           wangding@OFFICE
<span class="token comment"># 加上参数-v可以直接显示出来对应的所有内容</span>
* About to connect<span class="token punctuation">(</span><span class="token punctuation">)</span> to sample.wangding.in port 80 <span class="token punctuation">(</span><span class="token comment">#0)</span>
*   Trying 185.199.109.153<span class="token punctuation">..</span>. <span class="token comment"># dns解析出对应的域名</span>
* Connected to sample.wangding.in <span class="token punctuation">(</span>185.199.109.153<span class="token punctuation">)</span> port 80 <span class="token punctuation">(</span><span class="token comment">#0) # 进行TCP连接</span>
<span class="token operator">></span> GET /web/one-div.html HTTP/1.1
<span class="token operator">></span> User-Agent: curl/7.29.0
<span class="token operator">></span> Host: sample.wangding.in
<span class="token operator">></span> Accept: */*
<span class="token operator">></span> 
<span class="token operator"><</span> HTTP/1.1 200 OK
<span class="token operator"><</span> Server: GitHub.com
<span class="token operator"><</span> Content-Type: text/html<span class="token punctuation">;</span> charset<span class="token operator">=</span>utf-8
<span class="token operator"><</span> Last-Modified: Wed, 13 Jun 2018 08:24:27 GMT
<span class="token operator"><</span> ETag: <span class="token string">"5b20d4bb-146"</span>
<span class="token operator"><</span> Access-Control-Allow-Origin: *
<span class="token operator"><</span> Expires: Tue, 30 Oct 2018 07:07:45 GMT
<span class="token operator"><</span> Cache-Control: max-age<span class="token operator">=</span>600
<span class="token operator"><</span> X-GitHub-Request-Id: 2D16:563C:2485737:2FF1319:5BD800E9
<span class="token operator"><</span> Content-Length: 326
<span class="token operator"><</span> Accept-Ranges: bytes
<span class="token operator"><</span> Date: Tue, 30 Oct 2018 07:00:27 GMT
<span class="token operator"><</span> Via: 1.1 varnish
<span class="token operator"><</span> Age: 162
<span class="token operator"><</span> Connection: keep-alive
<span class="token operator"><</span> X-Served-By: cache-hkg17921-HKG
<span class="token operator"><</span> X-Cache: HIT
<span class="token operator"><</span> X-Cache-Hits: 4
<span class="token operator"><</span> X-Timer: S1540882828.772362,VS0,VE0
<span class="token operator"><</span> Vary: Accept-Encoding
<span class="token operator"><</span> X-Fastly-Request-ID: 84d0102672d42d756ed3d4ef8a8c8f7ccea8b776
<span class="token operator"><</span> 
<span class="token operator"><</span><span class="token operator">!</span>DOCTYPE html<span class="token operator">></span>
<span class="token operator"><</span>html<span class="token operator">></span>
  <span class="token operator"><</span>head<span class="token operator">></span>
    <span class="token operator"><</span>meta charset<span class="token operator">=</span><span class="token string">"UTF-8"</span><span class="token operator">></span>
    <span class="token operator"><</span>title<span class="token operator">></span><span class="token operator"><</span><span class="token operator">></span>ne div game<span class="token operator"><</span>/title<span class="token operator">></span>
    <span class="token operator"><</span>style type<span class="token operator">=</span><span class="token string">"text/css"</span><span class="token operator">></span>
      <span class="token comment">#game {</span>
        width: 100px<span class="token punctuation">;</span>
        height: 100px<span class="token punctuation">;</span>
        background-color: green<span class="token punctuation">;</span>
        margin: 100px auto<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token operator"><</span>/style<span class="token operator">></span>
  <span class="token operator"><</span>/head<span class="token operator">></span>
  <span class="token operator"><</span>body<span class="token operator">></span>
      <span class="token operator"><</span>div id<span class="token operator">=</span><span class="token string">"game"</span><span class="token operator">></span><span class="token operator"><</span>/div<span class="token operator">></span>
  <span class="token operator"><</span>/body<span class="token operator">></span>
<span class="token operator"><</span>/html<span class="token operator">></span>
* Connection <span class="token comment">#0 to host sample.wangding.in left intact</span>
</code></pre> 
  <p></p> 
  <h4>GET和POST方法</h4> 
  <ul> 
   <li>get方法</li> 
  </ul> 
  <p><a href="http://img.e-com-net.com/image/info8/3202501015614f70a824ce7ed3a265ee.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/3202501015614f70a824ce7ed3a265ee.jpg" alt="HTTP网络编程(客户端)_第3张图片" width="533" height="304" style="border:1px solid black;"></a></p> 
  <ul> 
   <li>post方法</li> 
  </ul> 
  <p><a href="http://img.e-com-net.com/image/info8/b35b53a89f32423b8d2c57fbe8308d21.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/b35b53a89f32423b8d2c57fbe8308d21.jpg" alt="HTTP网络编程(客户端)_第4张图片" width="564" height="293" style="border:1px solid black;"></a></p> 
  <p><a href="http://img.e-com-net.com/image/info8/654e809800854a089469a6bf157a1876.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/654e809800854a089469a6bf157a1876.jpg" alt="HTTP网络编程(客户端)_第5张图片" width="650" height="422" style="border:1px solid black;"></a></p> 
  <h5>实现 HTTP 客户端</h5> 
  <ul> 
   <li>可以解释命令行参数,命令行参数是要请求的 URL 地址</li> 
   <li>向指定的 URL 地址发出 GET 请求</li> 
   <li>将 HTTP 响应的报文头和报文体内容打印到控制台</li> 
   <li>用 http 模块的 get 方法</li> 
   <li>定义 user-agent 为 01-my-curl</li> 
  </ul> 
  <pre><code class="prism language-javascript">#<span class="token operator">!</span><span class="token operator">/</span>usr<span class="token operator">/</span>bin<span class="token operator">/</span>node

<span class="token keyword">const</span> http <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'http'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      url <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'url'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> address <span class="token operator">=</span> process<span class="token punctuation">.</span>argv<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">||</span> <span class="token string">'http://localhost:8080'</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> options <span class="token operator">=</span> <span class="token punctuation">{</span>
  hostname<span class="token punctuation">:</span>url<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">.</span>hostname<span class="token punctuation">,</span>
  prot<span class="token punctuation">:</span>url<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">.</span>prot<span class="token punctuation">,</span>
  path<span class="token punctuation">:</span>url<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">.</span>pathname<span class="token punctuation">,</span>
  headers<span class="token punctuation">:</span><span class="token punctuation">{</span>
    <span class="token string">'User-Agent'</span><span class="token punctuation">:</span><span class="token string">'01-my-curl'</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
http<span class="token punctuation">.</span><span class="token keyword">get</span><span class="token punctuation">(</span>options<span class="token punctuation">,</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'http/'</span><span class="token operator">+</span>res<span class="token punctuation">.</span>httpVersion<span class="token punctuation">,</span>res<span class="token punctuation">.</span>statusCode<span class="token punctuation">,</span>res<span class="token punctuation">.</span>statusMessage<span class="token punctuation">)</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>headers<span class="token punctuation">)</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  res<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>process<span class="token punctuation">.</span>stdout<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> 
  <pre><code class="prism language-bash"><span class="token comment"># 程序运行结果</span>
~/node.js/nodejs-demo/16-http<span class="token punctuation">(</span>master*<span class="token punctuation">)</span> » ./01-my-curl.js
http/1.1 200 OK
<span class="token punctuation">{</span> date: <span class="token string">'Tue, 30 Oct 2018 13:01:33 GMT'</span>,
  connection: <span class="token string">'close'</span>,
  <span class="token string">'content-length'</span><span class="token keyword">:</span> <span class="token string">'11'</span> <span class="token punctuation">}</span>

hello world%

~/node.js/nodejs-demo/01-introduction<span class="token punctuation">(</span>master*<span class="token punctuation">)</span> » ./02-hello-world-server.js 
<span class="token comment"># 定义 user-agent 为 01-my-curl</span>
<span class="token punctuation">{</span> <span class="token string">'user-agent'</span><span class="token keyword">:</span> <span class="token string">'01-my-curl'</span>,
  host: <span class="token string">'localhost:8080'</span>,
  connection: <span class="token string">'close'</span> <span class="token punctuation">}</span>
</code></pre> 
  <h5>对 HTTP 接口发出 GET 请求</h5> 
  <ul> 
   <li> <p>调用天气预报 API,实现城市天气查询:https://www.juhe.cn/docs/api/id/39</p> </li> 
   <li> <p>用 GET 方法请求天气信息</p> </li> 
   <li> <p>获取某个账户的所有 GitHub 仓库的数量和名称</p> </li> 
   <li> <p>API 地址:<code>https://api.github.com/search/repositories?q=user:wangding</code></p> </li> 
   <li> <p>API 参考:https://developer.github.com/v3/</p> </li> 
  </ul> 
  <pre><code class="prism language-javascript"><span class="token comment">/*get-weather*/</span>
#<span class="token operator">!</span><span class="token operator">/</span>usr<span class="token operator">/</span>bin<span class="token operator">/</span>node

<span class="token keyword">const</span> http <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'http'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> city <span class="token operator">=</span> process<span class="token punctuation">.</span>argv<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">||</span> <span class="token string">'石家庄'</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> address <span class="token operator">=</span> <span class="token string">'http://v.juhe.cn/weather/index?format=2&cityname='</span><span class="token operator">+</span> city <span class="token operator">+</span> <span class="token string">'&key=089c1db918016aa1643dcc167dc789fb'</span><span class="token punctuation">;</span>

http<span class="token punctuation">.</span><span class="token keyword">get</span><span class="token punctuation">(</span>global<span class="token punctuation">.</span><span class="token function">encodeURI</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  <span class="token keyword">var</span> result <span class="token operator">=</span> <span class="token string">''</span><span class="token punctuation">;</span>
  
  res<span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">'data'</span><span class="token punctuation">,</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  	result <span class="token operator">+=</span> data<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token string">'utf-8'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  
  res<span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">'end'</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> 
  <pre><code class="prism language-javascript"><span class="token comment">/*get-repos*/</span>
#<span class="token operator">!</span><span class="token operator">/</span>usr<span class="token operator">/</span>bin<span class="token operator">/</span>node

<span class="token keyword">const</span> http <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'http'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">var</span> 
</code></pre> 
  <h5>发起 POST 请求</h5> 
  <ul> 
   <li>编写 03-post.js 脚本,向指定的 URL 地址发出 HTTP POST 请求</li> 
   <li>并且 POST 请求中,携带向服务器程序发送的特定数据</li> 
   <li>将 HTTP 响应的报文头和报文体内容打印到控制台</li> 
   <li>编写 03-server.js 脚本,接收 03-post.js 脚本发送的 POST 请求数据</li> 
   <li>将接收到的数据打开到控制台</li> 
  </ul> 
  <pre><code class="prism language-javascript"><span class="token comment">/*03-server.js*/</span>
#<span class="token operator">!</span><span class="token operator">/</span>usr<span class="token operator">/</span>bin<span class="token operator">/</span>node

<span class="token keyword">const</span> http <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'http'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

http<span class="token punctuation">.</span><span class="token function">createServer</span><span class="token punctuation">(</span><span class="token punctuation">(</span>req<span class="token punctuation">,</span>res<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>req<span class="token punctuation">.</span>headers<span class="token punctuation">)</span><span class="token punctuation">;</span>
  	req<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>process<span class="token punctuation">.</span>stdout<span class="token punctuation">)</span><span class="token punctuation">;</span>
  	res<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token string">'OK!'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">listen</span><span class="token punctuation">(</span><span class="token number">8080</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> 
  <pre><code class="prism language-javascript"><span class="token comment">/*03-post.js*/</span>
#<span class="token operator">!</span><span class="token operator">/</span>usr<span class="token operator">/</span>bin<span class="token operator">/</span>node

<span class="token keyword">const</span> http <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'http'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      url <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'url'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> address <span class="token operator">=</span> process<span class="token punctuation">.</span>argv<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span> <span class="token operator">||</span> <span class="token string">'http://localhost:8080'</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> options <span class="token operator">=</span> <span class="token punctuation">{</span>
  hostname<span class="token punctuation">:</span>url<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">.</span>hostname<span class="token punctuation">;</span>
  prot<span class="token punctuation">:</span>url<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">.</span>prot<span class="token punctuation">,</span>
  path<span class="token punctuation">:</span>url<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">.</span>pathname<span class="token punctuation">,</span>
  method<span class="token punctuation">:</span><span class="token string">'POST'</span><span class="token punctuation">,</span>
  headers<span class="token punctuation">:</span><span class="token punctuation">{</span>
    <span class="token string">'User-Agent'</span><span class="token punctuation">:</span><span class="token string">'03-server'</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> req <span class="token operator">=</span> http<span class="token punctuation">.</span><span class="token function">request</span><span class="token punctuation">(</span>options<span class="token punctuation">,</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'http/'</span><span class="token operator">+</span>res<span class="token punctuation">.</span>httpVersion<span class="token punctuation">,</span>res<span class="token punctuation">.</span>statusCode<span class="token punctuation">,</span>res<span class="token punctuation">.</span>statusMessage<span class="token punctuation">)</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>headers<span class="token punctuation">)</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  res<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>process<span class="token punctuation">.</span>stdout<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
req<span class="token punctuation">.</span><span class="token function">write</span><span class="token punctuation">(</span><span class="token string">"{'name':'wangding'}'"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
req<span class="token punctuation">.</span><span class="token function">end</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> 
  <p>程序运行结果</p> 
  <pre><code class="prism language-bash"><span class="token comment"># 前台得到的消息</span>
~/node.js/nodejs-demo/16-http<span class="token punctuation">(</span>master*<span class="token punctuation">)</span> » ./03-post.js            wangding@OFFICE
HTTP/1.1 200 OK
<span class="token punctuation">{</span> date: <span class="token string">'Tue, 30 Oct 2018 13:19:48 GMT'</span>,
  connection: <span class="token string">'close'</span>,
  <span class="token string">'content-length'</span><span class="token keyword">:</span> <span class="token string">'3'</span> <span class="token punctuation">}</span>

OK<span class="token operator">!</span>%

<span class="token comment"># 服务器得到的消息</span>
~/node.js/nodejs-demo/16-http<span class="token punctuation">(</span>master*<span class="token punctuation">)</span> » ./03-server.js          wangding@OFFICE
<span class="token punctuation">{</span> <span class="token string">'user-agent'</span><span class="token keyword">:</span> <span class="token string">'03-server'</span>,
  host: <span class="token string">'localhost:8080'</span>,
  connection: <span class="token string">'close'</span>,
  <span class="token string">'transfer-encoding'</span><span class="token keyword">:</span> <span class="token string">'chunked'</span> <span class="token punctuation">}</span>
<span class="token punctuation">{</span><span class="token string">""</span>name<span class="token string">":"</span>wangding<span class="token string">""</span><span class="token punctuation">}</span>
</code></pre> 
  <h4>编写爬虫程序</h4> 
  <ul> 
   <li>创建 04-crawler 目录,创建项目配置文件:package.json</li> 
   <li><code>npm i -S cheerio</code> 安装项目依赖 cheerio</li> 
   <li>用 cheerio 对爬取的 HTML 页面进行 DOM 元素解析</li> 
   <li>cheerio 用法请参考:cheerio API</li> 
   <li>爬取 51CTO 学院所有的免费课程信息</li> 
   <li>需爬取的网页地址:http://edu.51cto.com/courselist/index-zh5.html</li> 
   <li>从爬取的网页中解析出课程信息,包括:课程名称,课程时长,课程地址,教学目标</li> 
   <li>将爬取的课程信息格式化输出到控制台</li> 
   <li>实现多任务并发爬取</li> 
  </ul> 
  <pre><code class="prism language-javascript"><span class="token comment">/*
1. npm init 创建项目配置文件
2. npm i -S cheerio 安装项目依赖cheerio (i的目的是为了自动加入到package.json上去)
*/</span>

#<span class="token operator">!</span><span class="token operator">/</span>usr<span class="token operator">/</span>bin<span class="token operator">/</span>node

<span class="token keyword">const</span> http <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'http'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      cheerio <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'cheerio'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">var</span> i <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>i<span class="token operator"><</span><span class="token number">87</span><span class="token punctuation">;</span>i<span class="token operator">++</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">var</span> address <span class="token operator">=</span> <span class="token string">'http://edu.51cto.com/courselist/index-zh5-p'</span> <span class="token operator">+</span> i <span class="token operator">+</span> <span class="token string">'.html'</span><span class="token punctuation">;</span>
  http<span class="token punctuation">.</span><span class="token keyword">get</span><span class="token punctuation">(</span>address<span class="token punctuation">,</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  	<span class="token keyword">var</span> html <span class="token operator">=</span> <span class="token string">''</span><span class="token punctuation">;</span>
    
    res<span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">'data'</span><span class="token punctuation">,</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
  		html <span class="token operator">+=</span>data<span class="token punctuation">;</span>
	<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    
    res<span class="token punctuation">.</span><span class="token function">on</span><span class="token punctuation">(</span><span class="token string">'end'</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
        <span class="token comment">// 沿用JQuery风格,定义$</span>
  		<span class="token keyword">var</span> $ <span class="token operator">=</span> cheerio<span class="token punctuation">.</span><span class="token function">load</span><span class="token punctuation">(</span>html<span class="token punctuation">)</span><span class="token punctuation">;</span>
    	<span class="token function">$</span><span class="token punctuation">(</span><span class="token string">'body'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token string">'div.main'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">each</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  			<span class="token keyword">var</span> cName <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">text</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                cTime <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token string">'p.fl'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">text</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                cTarget <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token string">'div.course_target'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">text</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
                cUrl <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">'href'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          	<span class="token keyword">if</span><span class="token punctuation">(</span>cTime <span class="token operator">===</span> <span class="token string">''</span><span class="token punctuation">)</span> <span class="token keyword">return</span><span class="token punctuation">;</span>
          	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'课程名称:'</span><span class="token punctuation">,</span>cName<span class="token punctuation">)</span><span class="token punctuation">;</span>
          	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'课程时长:'</span><span class="token punctuation">,</span>cTime<span class="token punctuation">)</span><span class="token punctuation">;</span>
          	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'课程目标:'</span><span class="token punctuation">,</span>cTarget<span class="token punctuation">)</span><span class="token punctuation">;</span>
          	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'课程地址:'</span><span class="token punctuation">,</span>cUrl<span class="token punctuation">)</span><span class="token punctuation">;</span>
		<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token comment">/*
运行结果
./index.js > out.html 重定向到了out.html里面
cat out | wc -l 统计out.html的行数
9856
*/</span>
</code></pre> 
  <h4>处理 HTTP 重定向</h4> 
  <ul> 
   <li>实现对 HTTP 协议的重定向状态的处理</li> 
   <li>测试 URL:http://www.sian.com/</li> 
   <li>需要获取重定向后的最终页面</li> 
   <li>将最终页面输出到控制台</li> 
  </ul> 
  <p>程序运行结果</p> 
  <p><a href="http://img.e-com-net.com/image/info8/e0228297a5cf495086f0e659460e8f08.png" target="_blank"><img src="http://img.e-com-net.com/image/info8/e0228297a5cf495086f0e659460e8f08.png" alt="HTTP网络编程(客户端)_第6张图片" width="616" height="165" style="border:1px solid black;"></a></p> 
  <p><a href="http://img.e-com-net.com/image/info8/a8b35d16f8ba4bae84d380cdef1980a7.png" target="_blank"><img src="http://img.e-com-net.com/image/info8/a8b35d16f8ba4bae84d380cdef1980a7.png" alt="HTTP网络编程(客户端)_第7张图片" width="561" height="166" style="border:1px solid black;"></a></p> 
  <p><a href="http://img.e-com-net.com/image/info8/5a6b98df90e94edbae10aa8de90ff2f6.png" target="_blank"><img src="http://img.e-com-net.com/image/info8/5a6b98df90e94edbae10aa8de90ff2f6.png" alt="HTTP网络编程(客户端)_第8张图片" width="625" height="158" style="border:1px solid black;"></a></p> 
  <p><a href="http://img.e-com-net.com/image/info8/271ae4086a094d849eba03277aae9866.jpg" target="_blank"><img src="http://img.e-com-net.com/image/info8/271ae4086a094d849eba03277aae9866.jpg" alt="HTTP网络编程(客户端)_第9张图片" width="650" height="216" style="border:1px solid black;"></a></p> 
  <pre><code class="prism language-javascript">#<span class="token operator">!</span><span class="token operator">/</span>usr<span class="token operator">/</span>bin<span class="token operator">/</span>node

<span class="token keyword">const</span> http <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'http'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      url <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'url'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">var</span> address <span class="token operator">=</span> <span class="token string">'http://www.sian.com/'</span><span class="token punctuation">;</span>

<span class="token keyword">function</span> <span class="token function">getOption</span><span class="token punctuation">(</span>addr<span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">var</span> options <span class="token operator">=</span> url<span class="token punctuation">.</span><span class="token function">parse</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">;</span>
  
  options<span class="token punctuation">.</span>headers <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">'User-Agent'</span><span class="token punctuation">:</span><span class="token string">'curl/7.0'</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
  <span class="token keyword">return</span> options<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword">function</span> <span class="token function">getUrl</span><span class="token punctuation">(</span>options<span class="token punctuation">)</span><span class="token punctuation">{</span>
  http<span class="token punctuation">.</span><span class="token function">createServer</span><span class="token punctuation">(</span><span class="token punctuation">(</span>req<span class="token punctuation">,</span>res<span class="token punctuation">)</span><span class="token operator">=></span><span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'HTTP/'</span> <span class="token operator">+</span> res<span class="token punctuation">.</span>httpVersion<span class="token punctuation">,</span>res<span class="token punctuation">.</span>statusCode<span class="token punctuation">,</span>res<span class="token punctuation">.</span>statusMessage<span class="token punctuation">)</span><span class="token punctuation">;</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>headers<span class="token punctuation">)</span><span class="token punctuation">;</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>res<span class="token punctuation">.</span>statusCode <span class="token operator">></span> <span class="token number">300</span> <span class="token operator">&&</span> res<span class="token punctuation">.</span>statusCode <span class="token operator"><</span><span class="token number">400</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  		<span class="token keyword">var</span> newAddr <span class="token operator">=</span> res<span class="token punctuation">.</span>headers<span class="token punctuation">[</span><span class="token string">'location'</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
      	<span class="token function">getUrl</span><span class="token punctuation">(</span><span class="token function">getOption</span><span class="token punctuation">(</span>newAddr<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span><span class="token keyword">else</span><span class="token punctuation">{</span>
  		res<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>process<span class="token punctuation">.</span>stdout<span class="token punctuation">)</span><span class="token punctuation">;</span>
	<span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token function">getUrl</span><span class="token punctuation">(</span><span class="token function">getOption</span><span class="token punctuation">(</span>address<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> 
  <p>程序运行结果</p> 
  <pre><code class="prism language-bash">~/node.js/nodejs-demo/16-http<span class="token punctuation">(</span>master*<span class="token punctuation">)</span> » ./05-redirection.js     wangding@OFFIC
HTTP/1.1 301 Moved Permanently
<span class="token punctuation">{</span> server: <span class="token string">'nginx/1.8.0'</span>,
  date: <span class="token string">'Wed, 31 Oct 2018 09:52:41 GMT'</span>,
  <span class="token string">'content-type'</span><span class="token keyword">:</span> <span class="token string">'text/html'</span>,
  <span class="token string">'content-length'</span><span class="token keyword">:</span> <span class="token string">'184'</span>,
  connection: <span class="token string">'close'</span>,
  location: <span class="token string">'http://sian.com/'</span> <span class="token punctuation">}</span>

HTTP/1.1 302 Moved Temporarily
<span class="token punctuation">{</span> server: <span class="token string">'nginx/1.8.0'</span>,
  date: <span class="token string">'Wed, 31 Oct 2018 09:52:42 GMT'</span>,
  <span class="token string">'content-type'</span><span class="token keyword">:</span> <span class="token string">'text/html'</span>,
  <span class="token string">'content-length'</span><span class="token keyword">:</span> <span class="token string">'160'</span>,
  connection: <span class="token string">'close'</span>,
  location: <span class="token string">'http://www.sportsworldtl.com/'</span> <span class="token punctuation">}</span>

HTTP/1.1 302 Moved Temporarily
<span class="token punctuation">{</span> server: <span class="token string">'Apache-Coyote/1.1'</span>,
  <span class="token string">'set-cookie'</span><span class="token keyword">:</span> <span class="token punctuation">[</span> <span class="token string">'JSESSIONID=C3F4D55A3A87FE4E2CF2E881A0ECA371; Path=/; HttpOnly'</span> <span class="token punctuation">]</span>,
  location: <span class="token string">'http://www.sportsworldtl.com/index.ac'</span>,
  <span class="token string">'content-type'</span><span class="token keyword">:</span> <span class="token string">'text/html;charset=UTF-8'</span>,
  <span class="token string">'content-length'</span><span class="token keyword">:</span> <span class="token string">'0'</span>,
  date: <span class="token string">'Wed, 31 Oct 2018 09:52:42 GMT'</span>,
  connection: <span class="token string">'close'</span> <span class="token punctuation">}</span>

HTTP/1.1 200 OK
<span class="token punctuation">{</span> server: <span class="token string">'Apache-Coyote/1.1'</span>,
  <span class="token string">'set-cookie'</span><span class="token keyword">:</span> <span class="token punctuation">[</span> <span class="token string">'JSESSIONID=077BD21F2C6A2B594F1EE36956398E2C; Path=/; HttpOnly'</span> <span class="token punctuation">]</span>,
  <span class="token string">'content-type'</span><span class="token keyword">:</span> <span class="token string">'text/html;charset=utf-8'</span>,
  <span class="token string">'content-language'</span><span class="token keyword">:</span> <span class="token string">'zh-CN'</span>,
  <span class="token string">'content-length'</span><span class="token keyword">:</span> <span class="token string">'1640'</span>,
  vary: <span class="token string">'Accept-Encoding'</span>,
  date: <span class="token string">'Wed, 31 Oct 2018 09:52:42 GMT'</span>,
  connection: <span class="token string">'close'</span> <span class="token punctuation">}</span>

<span class="token operator"><</span><span class="token operator">!</span>DOCTYPE html<span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">!</span>--<span class="token punctuation">[</span>if IE 8<span class="token punctuation">]</span><span class="token operator">></span> <span class="token operator"><</span>html lang<span class="token operator">=</span><span class="token string">"zh-CN"</span> class<span class="token operator">=</span><span class="token string">"ie8 no-js"</span><span class="token operator">></span> <span class="token operator"><</span><span class="token operator">!</span><span class="token punctuation">[</span>endif<span class="token punctuation">]</span>--<span class="token operator">></span><span class="token operator"><</span><span class="token operator">!</span>--<span class="token punctuation">[</span>if IE 9<span class="token punctuation">]</span><span class="token operator">></span> <span class="token operator"><</span>html lang<span class="token operator">=</span><span class="token string">"zh-CN"</span> class<span class="token operator">=</span><span class="token string">"ie9 no-js"</span><span class="token operator">></span> <span class="token operator"><</span><span class="token operator">!</span><span class="token punctuation">[</span>endif<span class="token punctuation">]</span>--<span class="token operator">></span><span class="token operator"><</span><span class="token operator">!</span>--<span class="token punctuation">[</span>if <span class="token operator">!</span>IE<span class="token punctuation">]</span><span class="token operator">></span><span class="token operator"><</span><span class="token operator">!</span>--<span class="token operator">></span> <span class="token operator"><</span>html lang<span class="token operator">=</span><span class="token string">"zh-CN"</span> class<span class="token operator">=</span><span class="token string">"no-js"</span><span class="token operator">></span> <span class="token operator"><</span><span class="token operator">!</span>--<span class="token operator"><</span><span class="token operator">!</span><span class="token punctuation">[</span>endif<span class="token punctuation">]</span>--<span class="token operator">></span>
<span class="token operator"><</span><span class="token operator">!</span>-- END BODY --<span class="token operator">></span>
<span class="token operator"><</span>/html<span class="token operator">></span>
</code></pre> 
 </div> 
</div>
                            </div>
                        </div>
                    </div>
                    <!--PC和WAP自适应版-->
                    <div id="SOHUCS" sid="1187764558740168704"></div>
                    <script type="text/javascript" src="/views/front/js/chanyan.js"></script>
                    <!-- 文章页-底部 动态广告位 -->
                    <div class="youdao-fixed-ad" id="detail_ad_bottom"></div>
                </div>
                <div class="col-md-3">
                    <div class="row" id="ad">
                        <!-- 文章页-右侧1 动态广告位 -->
                        <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_1"> </div>
                        </div>
                        <!-- 文章页-右侧2 动态广告位 -->
                        <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_2"></div>
                        </div>
                        <!-- 文章页-右侧3 动态广告位 -->
                        <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad">
                            <div class="youdao-fixed-ad" id="detail_ad_3"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(node.js)</h4>
        <div id="paradigm-article-related">
            <div class="recommend-post mb30">
                <ul class="widget-links">
                    <li><a href="/article/1835492740536823808.htm"
                           title="node.js学习" target="_blank">node.js学习</a>
                        <span class="text-muted">小猿L</span>
<a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a><a class="tag" taget="_blank" href="/search/vim/1.htm">vim</a>
                        <div>node.js学习实操及笔记温故node.js,node.js学习实操过程及笔记~node.js学习视频node.js官网node.js中文网实操笔记githubcsdn笔记为什么学node.js可以让别人访问我们编写的网页为后续的框架学习打下基础,三大框架vuereactangular离不开node.jsnode.js是什么官网:node.js是一个开源的、跨平台的运行JavaScript的运行</div>
                    </li>
                    <li><a href="/article/1835431726982197248.htm"
                           title="vue 创建项目报错:command failed: npm install --loglevel error" target="_blank">vue 创建项目报错:command failed: npm install --loglevel error</a>
                        <span class="text-muted">那鱼、会飞</span>
<a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/vue-cli3/1.htm">vue-cli3</a>
                        <div>这个问题其实很好解决,只是很多种情况,逐一排除即可。稳下心来~vuecli3创建项目我的node版本是node14.15.0,(永远不要尝试最新版本)node各种版本下载地址:以往的版本|Node.js(nodejs.org)vue/cli@3.12.1npminstall-g@vue/cli@3.12.1(注意vue/cli2和vue/cli3的下载命名有所改变,2是-形式,3是/形式)其实报错</div>
                    </li>
                    <li><a href="/article/1835430719363575808.htm"
                           title="更改npm镜像源为淘宝镜像" target="_blank">更改npm镜像源为淘宝镜像</a>
                        <span class="text-muted">骆小骆</span>
<a class="tag" taget="_blank" href="/search/%E5%9F%BA%E4%BA%8Enode.js/1.htm">基于node.js</a>
                        <div>npm常用指令后缀*最近复习了一下node.js整理了一下跟node.js相关的指令后缀*--save、-S参数意思是把模块的版本信息保存到dependencies(生产环境依赖)中,即你的package.json文件的dependencies字段中;–--save-dev、-D参数意思是把模块版本信息保存到devDependencies(开发环境依赖)中,即你的package.json文件的de</div>
                    </li>
                    <li><a href="/article/1835288964056051712.htm"
                           title="分享一个基于python的电子书数据采集与可视化分析 hadoop电子书数据分析与推荐系统 spark大数据毕设项目(源码、调试、LW、开题、PPT)" target="_blank">分享一个基于python的电子书数据采集与可视化分析 hadoop电子书数据分析与推荐系统 spark大数据毕设项目(源码、调试、LW、开题、PPT)</a>
                        <span class="text-muted">计算机源码社</span>
<a class="tag" taget="_blank" href="/search/Python%E9%A1%B9%E7%9B%AE/1.htm">Python项目</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a><a class="tag" taget="_blank" href="/search/%E5%A4%A7%E6%95%B0%E6%8D%AE/1.htm">大数据</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/hadoop/1.htm">hadoop</a><a class="tag" taget="_blank" href="/search/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E9%80%89%E9%A2%98/1.htm">计算机毕业设计选题</a><a class="tag" taget="_blank" href="/search/%E8%AE%A1%E7%AE%97%E6%9C%BA%E6%AF%95%E4%B8%9A%E8%AE%BE%E8%AE%A1%E6%BA%90%E7%A0%81/1.htm">计算机毕业设计源码</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/1.htm">数据分析</a><a class="tag" taget="_blank" href="/search/spark%E6%AF%95%E8%AE%BE/1.htm">spark毕设</a>
                        <div>作者:计算机源码社个人简介:本人八年开发经验,擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等,大家有这一块的问题可以一起交流!学习资料、程序开发、技术解答、文档报告如需要源码,可以扫取文章下方二维码联系咨询Java项目微信小程序项目Android项目Python项目PHP项目ASP.NET项目Node.js项目选题推荐项目实战|p</div>
                    </li>
                    <li><a href="/article/1835259969688137728.htm"
                           title="axios 请求封装" target="_blank">axios 请求封装</a>
                        <span class="text-muted">web Rookie</span>
<a class="tag" taget="_blank" href="/search/%E5%B7%A5%E4%BD%9C/1.htm">工作</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a><a class="tag" taget="_blank" href="/search/ajax/1.htm">ajax</a>
                        <div>文章目录1.前言2.axios下载3.代码实现4.实际使用1.前言本文是对于axios的二次封装处理,axios是一个基于Promise的网络请求库,作用于node.js和浏览器中;本文对于axios中的封装着重于直接使用,如果想要学习axios相关知识可以先行离开,后续在对其进行完善2.axios下载npminstallaxios3.代码实现//request.tsimportaxios,{Ax</div>
                    </li>
                    <li><a href="/article/1835229087489159168.htm"
                           title="为什么Node.js不适合CPU密集型应用?" target="_blank">为什么Node.js不适合CPU密集型应用?</a>
                        <span class="text-muted">weixin_54503231</span>
<a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a>
                        <div>Node.js不适合CPU密集型应用的原因主要基于其设计理念和核心特性,具体可以归纳为以下几点:单线程模型Node.js采用单线程模型来处理用户请求和异步I/O操作。虽然这种模型在处理高并发I/O密集型任务时非常高效,因为它避免了传统多线程模型中的线程上下文切换开销,但这也意味着它不能充分利用现代多核CPU的计算能力。对于需要大量计算资源的CPU密集型应用,单线程模型会成为瓶颈,导致应用性能受限。</div>
                    </li>
                    <li><a href="/article/1835222787472584704.htm"
                           title="计算机毕设Node.js+Vue校园易购二手交易平台(程序+LW+部署)" target="_blank">计算机毕设Node.js+Vue校园易购二手交易平台(程序+LW+部署)</a>
                        <span class="text-muted">Node程序源码强子</span>
<a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/%E8%AF%BE%E7%A8%8B%E8%AE%BE%E8%AE%A1/1.htm">课程设计</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a>
                        <div>项目运行环境配置:Node.js最新版+Vscode+Mysql5.7+HBuilderX+Navicat11+Vue。项目技术:Express框架+Node.js+Vue等等组成,B/S模式+Vscode管理+前后端分离等等。环境需要1.运行环境:最好是Nodejs最新版,我们在这个版本上开发的。其他版本理论上也可以。2.开发</div>
                    </li>
                    <li><a href="/article/1835098066269597696.htm"
                           title="pnpm解說" target="_blank">pnpm解說</a>
                        <span class="text-muted">白总Server</span>
<a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/kubernetes/1.htm">kubernetes</a><a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C/1.htm">网络</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E4%BA%91%E5%8E%9F%E7%94%9F/1.htm">云原生</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a>
                        <div>pnpm(PerformanceNodePackageManager)是一个高性能的Node.js包管理器,它旨在解决npm和yarn在处理依赖关系时可能遇到的一些问题,如重复安装相同版本的包、包的存储空间占用过大等。pnpm使用了一种称为“硬链接”和“符号链接”的文件系统技术,这使得它能够以更高效的方式存储和管理依赖项。关键特点:高效存储:pnpm使用一种称为内容可寻址存储(ContentAdd</div>
                    </li>
                    <li><a href="/article/1834919912410279936.htm"
                           title="Tapable" target="_blank">Tapable</a>
                        <span class="text-muted">信海利世</span>
<a class="tag" taget="_blank" href="/search/webpack/1.htm">webpack</a><a class="tag" taget="_blank" href="/search/webpack/1.htm">webpack</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a>
                        <div>一、Tapable是什么?Tapable是一个类似于Node.js的EventEmitter的库,主要是控制钩子函数的发布与订阅,控制着webpack的插件系统。Tapable库暴露了很多Hook(钩子)类,为插件提供挂载的钩子const{SyncHook,//同步钩子SyncBailHook,//同步熔断钩子即return一个非undefined的值,则不再继续执行后面的监听函数SyncWate</div>
                    </li>
                    <li><a href="/article/1834832183529926656.htm"
                           title="用前端的语言写后端——Node.js之Express" target="_blank">用前端的语言写后端——Node.js之Express</a>
                        <span class="text-muted">tabzzz</span>
<a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/express/1.htm">express</a>
                        <div>ExpressExpress是一种流行的模型视图控制器(MVC)Node.js框架,具有快速、极简和灵活的优点,为Web和移动应用程序开发提供了强大的功能集合。最受欢迎的Node.js框架!文章目录Express安装ExpressHelloWorld路由中间件全局中间件应用中间件开放跨域请求几种常用的Express内置中间件函数1.JSON格式数据中间件函数2.静态文件中间件函数3.路由中间件函数</div>
                    </li>
                    <li><a href="/article/1834793356543225856.htm"
                           title="由于篇幅和复杂性限制,我无法在这里直接为你提供一个完整的、用多种编程语言实现的购物商城代码。但是,我可以为你概述如何使用几种流行的编程语言(如Python, JavaScript/Node.js, J" target="_blank">由于篇幅和复杂性限制,我无法在这里直接为你提供一个完整的、用多种编程语言实现的购物商城代码。但是,我可以为你概述如何使用几种流行的编程语言(如Python, JavaScript/Node.js, J</a>
                        <span class="text-muted">NewmanEdwarda2</span>
<a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a>
                        <div>Python(后端,使用Flask或Django)Flask示例(后端API)gjijg.compythonfromflaskimportFlask,request,jsonifyapp=Flask(name)假设的数据库商品列表products=[{“id”:1,“name”:“苹果”,“price”:10.0},{“id”:2,“name”:“香蕉”,“price”:5.0},]@app.ro</div>
                    </li>
                    <li><a href="/article/1834743823390044160.htm"
                           title="微信小程序集成前端日志库" target="_blank">微信小程序集成前端日志库</a>
                        <span class="text-muted">人工智能的苟富贵</span>
<a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF%E5%B0%8F%E7%A8%8B%E5%BA%8F/1.htm">前端小程序</a><a class="tag" taget="_blank" href="/search/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/1.htm">微信小程序</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a>
                        <div>在微信小程序内接入日志库的记录在开发微信小程序时,为了更好地调试和维护代码,通常需要记录日志信息。我尝试了多种日志库,包括Winston、pion和loglevel,并最终选择了loglevel作为日志库,并实现了日志上传到服务器的功能。本文详细记录了这一过程,以供参考。使用Winston失败最初,我尝试在微信小程序中使用Winston日志库。然而,Winston依赖Node.js的部分核心模块(</div>
                    </li>
                    <li><a href="/article/1834700824790528000.htm"
                           title="安卓将本地日志上传到服务器" target="_blank">安卓将本地日志上传到服务器</a>
                        <span class="text-muted">胡子洲</span>
<a class="tag" taget="_blank" href="/search/Android/1.htm">Android</a><a class="tag" taget="_blank" href="/search/android/1.htm">android</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a>
                        <div>在安卓开发中,将本地日志上传到服务器是一个常见的需求,特别是在开发需要远程监控或调试的应用时。以下是一个基本的步骤和示例,说明如何实现这一功能:1本地日志上传到服务器1.1准备服务器首先,你需要在服务器上设置一个接口,用于接收上传的日志文件。这个接口可以是RESTfulAPI,使用HTTPPOST方法接收文件。你可以使用各种后端技术栈来实现这个接口,如Node.js、Python(Flask或Dj</div>
                    </li>
                    <li><a href="/article/1834631489283780608.htm"
                           title="Vue 图片预览功能实现指南" target="_blank">Vue 图片预览功能实现指南</a>
                        <span class="text-muted">繁依Fanyi</span>
<a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a><a class="tag" taget="_blank" href="/search/python/1.htm">python</a><a class="tag" taget="_blank" href="/search/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/1.htm">人工智能</a><a class="tag" taget="_blank" href="/search/%E7%AE%97%E6%B3%95/1.htm">算法</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a>
                        <div>1.介绍在现代web应用程序中,图片预览功能提升了用户体验,使用户可以在上传图片之前查看图片内容。本文将详细介绍如何在Vue.js应用中实现图片预览功能,包括基本实现、进阶功能、与ElementUI的集成、常见优化技巧以及与其他库的结合使用。2.基本功能实现2.1环境准备确保你的开发环境已经配置好,包括VueCLI和Node.js。如果还没有安装VueCLI,你可以通过以下命令安装:npminst</div>
                    </li>
                    <li><a href="/article/1834578434920116224.htm"
                           title="npm install 太慢?解决方法大揭秘" target="_blank">npm install 太慢?解决方法大揭秘</a>
                        <span class="text-muted">小柒笔记</span>
<a class="tag" taget="_blank" href="/search/npm/1.htm">npm</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a>
                        <div>本文将详细介绍如何解决npminstall命令执行速度慢的问题。文章将涵盖npminstall命令执行慢的原因、优化方法以及实际应用案例。通过本文的学习,读者可以掌握提高npminstall命令执行速度的基本技巧,并在实际项目中得心应手。引言npminstall是Node.js项目开发中的常用命令,用于安装项目依赖。然而,在某些情况下,npminstall命令的执行速度可能会变得非常慢,这可能影响</div>
                    </li>
                    <li><a href="/article/1834401727848214528.htm"
                           title="Vue3: Node安装下载" target="_blank">Vue3: Node安装下载</a>
                        <span class="text-muted">QGC二次开发</span>
<a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/vue/1.htm">vue</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a><a class="tag" taget="_blank" href="/search/%E4%BF%A1%E6%81%AF%E5%8F%AF%E8%A7%86%E5%8C%96/1.htm">信息可视化</a>
                        <div>目录一.Node网站链接二.安装node三.查看node安装是否成功一.Node网站链接Node.js中文网(nodejs.cn)下载20.17.0文档(长期支持版本)二.安装node一直next三.查看node安装是否成功安装成功后cmd打开本机终端,输入node查看是否安装成功。</div>
                    </li>
                    <li><a href="/article/1834364138277662720.htm"
                           title="6 vue-cli初步" target="_blank">6 vue-cli初步</a>
                        <span class="text-muted">洋baby</span>

                        <div>1.安装node.js下载安装node.js,一路默认安装即可,安装完毕,启动命令行,输入命令node-v,可以看到node.js的版本号image.png2.安装vue-cli使用npm(需要安装node环境)全局安装webpack,启动命令行,输入如下命令:npminstall-gwebpack耐心等待安装完成之后输入webpack-v,可以看到如图所示image.png从webpack4.X</div>
                    </li>
                    <li><a href="/article/1834363282077609984.htm"
                           title="【npm】解决npm安装慢问题" target="_blank">【npm】解决npm安装慢问题</a>
                        <span class="text-muted">逆旅行天涯</span>
<a class="tag" taget="_blank" href="/search/npm/1.htm">npm</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a>
                        <div>在Node.js开发过程中,npminstall是安装和管理项目依赖的关键命令。然而,有时我们会遇到npminstall运行卡住不动的情况,这通常与网络连接、NPM源的可用性和速度、资源下载超时等因素有关。本文将为你提供七种解决方案,帮助你顺利进行依赖安装。1.检查网络状况首要任务是确保您的计算机具有稳定的网络连接,并能无障碍访问外部资源。如果是在公司或校园内网环境下,检查是否存在防火墙限制或代理</div>
                    </li>
                    <li><a href="/article/1834357354934661120.htm"
                           title="Node.js 、Yarn、npm、Vue、Vite、Webpack 前端一套流程" target="_blank">Node.js 、Yarn、npm、Vue、Vite、Webpack 前端一套流程</a>
                        <span class="text-muted">叫我DPT</span>
<a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/1.htm">前端开发</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/npm/1.htm">npm</a>
                        <div>前端项目的搭建Vue、Vite、Webpack、Yarn、Node.js和npm的概念解释,以及它们之间的关系:Node.js:一个开源、跨平台的JavaScript运行时环境,可以让JavaScript代码在服务器端运行。它提供了一个事件驱动、非阻塞的I/O模型,使得它非常适合构建高性能的网络应用。Node.js基于ChromeV8引擎构建,能够执行JavaScript代码。npm(NodePa</div>
                    </li>
                    <li><a href="/article/1834207711894532096.htm"
                           title="学习node.js十三,文件的上传于下载" target="_blank">学习node.js十三,文件的上传于下载</a>
                        <span class="text-muted">涛涛酱10086</span>
<a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a>
                        <div>文件上传文件上传的方案:大文件上传:将大文件切分成较小的片段(通常称为分片或块),然后逐个上传这些分片。这种方法可以提高上传的稳定性,因为如果某个分片上传失败,只需要重新上传该分片而不需要重新上传整个文件。同时,分片上传还可以利用多个网络连接并行上传多个分片,提高上传速度断点续传:在上传过程中,如果网络中断或上传被中止,断点续传技术可以记录已成功上传的分片信息,以便在恢复上传时继续上传未完成的部分</div>
                    </li>
                    <li><a href="/article/1834151623425880064.htm"
                           title="Uni-app 开发鸿蒙 App 全攻略" target="_blank">Uni-app 开发鸿蒙 App 全攻略</a>
                        <span class="text-muted">老三不说话、</span>
<a class="tag" taget="_blank" href="/search/uni-app/1.htm">uni-app</a><a class="tag" taget="_blank" href="/search/harmonyos/1.htm">harmonyos</a>
                        <div>一、开发前的准备工作开发鸿蒙App之前,我们需要做好充分的准备工作。首先是工具的安装与配置。Node.js的安装:推荐使用LTS版本的Node.js。可以前往Node.js的官方网站下载适合自己操作系统的安装包,如Windows用户根据自己的系统版本选择32位或64位版本。安装过程较为简单,只需按照安装向导一步步进行操作,同意许可协议,选择安装位置即可。安装完成后,可以使用命令行工具(如Power</div>
                    </li>
                    <li><a href="/article/1834130448331141120.htm"
                           title="在 Vue 2 中使用 Axios 发起 POST 和 GET 请求" target="_blank">在 Vue 2 中使用 Axios 发起 POST 和 GET 请求</a>
                        <span class="text-muted">Jarvis Downey</span>
<a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/vue/1.htm">vue</a><a class="tag" taget="_blank" href="/search/vue.js/1.htm">vue.js</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a>
                        <div>Axios是一个基于Promise的HTTP客户端,用于浏览器和node.js,它提供了一种非常方便的方式来发送异步HTTP请求。在Vue2应用中,Axios可以帮助我们轻松地与后端API进行通信。本文将介绍如何在Vue2项目中引入Axios,并使用它来发起POST和GET请求。1.安装Axios首先,你需要在你的Vue项目中安装Axios。打开终端,切换到你的项目目录,然后运行以下命令:npmi</div>
                    </li>
                    <li><a href="/article/1834083054231056384.htm"
                           title="sqlite在Windows环境下安装、使用、node.js连接" target="_blank">sqlite在Windows环境下安装、使用、node.js连接</a>
                        <span class="text-muted">标准形与二次型</span>
<a class="tag" taget="_blank" href="/search/sqlite/1.htm">sqlite</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a>
                        <div>sqlite在Windows环境下安装、使用、node.js连接前言:2024年9月10日1.下载安装sqlite的安装非常简单去官网下载对应压缩包将两个压缩包解压,并将解压出来的文件放在同一目录下将上面的目录路径配置到环境变量path中2.执行sqlsqlite非常轻量级,执行命令和sql都可以通过cmd或解压出来的sqlite3.exe。但要注意:cmd执行sqlite3类似于双击sqlite</div>
                    </li>
                    <li><a href="/article/1833965828748439552.htm"
                           title="CentOS系统上Node.js安装与配置最佳实践" target="_blank">CentOS系统上Node.js安装与配置最佳实践</a>
                        <span class="text-muted">雾里看花_</span>
<a class="tag" taget="_blank" href="/search/Linux/1.htm">Linux</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/centos/1.htm">centos</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a>
                        <div>由于nvm下载node需要速度非常慢(试过很多次都不行),所以推荐手动安装,步骤也很简单1、官网下载打开官网Node.js官网下载选择自己系统合适的版本下载,我这里下载的是Linuxx64的v18.20版本2.上传服务器将下载好的包上传到服务器,我这里是安装了rz命令,也可以通过其他第三方软件上传解压tar-xvJfnode-v18.20.4-linux-x64.tar.xz3.创建软连接ln-s</div>
                    </li>
                    <li><a href="/article/1833938206698074112.htm"
                           title="“Debugger listening on [::]:25950” node.js调试时出现端口占用的问题,run没问题 debug时老提示端口占用 。Error: listen EADDRI" target="_blank">“Debugger listening on [::]:25950” node.js调试时出现端口占用的问题,run没问题 debug时老提示端口占用 。Error: listen EADDRI</a>
                        <span class="text-muted">acoolgiser</span>
<a class="tag" taget="_blank" href="/search/Node.JS/1.htm">Node.JS</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a><a class="tag" taget="_blank" href="/search/debug%E7%AB%AF%E5%8F%A3%E8%A2%AB%E5%8D%A0%E7%94%A8/1.htm">debug端口被占用</a><a class="tag" taget="_blank" href="/search/debug/1.htm">debug</a><a class="tag" taget="_blank" href="/search/%E5%8F%AF%E4%BB%A5run%E4%BD%86%E6%98%AF%E4%B8%8D%E8%83%BDdebug/1.htm">可以run但是不能debug</a><a class="tag" taget="_blank" href="/search/Error%3A/1.htm">Error:</a><a class="tag" taget="_blank" href="/search/listen/1.htm">listen</a><a class="tag" taget="_blank" href="/search/EADDRI/1.htm">EADDRI</a><a class="tag" taget="_blank" href="/search/Debugger/1.htm">Debugger</a><a class="tag" taget="_blank" href="/search/listening/1.htm">listening</a><a class="tag" taget="_blank" href="/search/on/1.htm">on</a>
                        <div>花了两天半时间!!!终于解决了这个问题。。。故总结于此在node.js多进程项目中,程序直接run没问题,但debug时老提示端口占用。“Debuggerlisteningon[::]:25951”node.js调试时出现端口占用的问题,。出现的错误为“Error:listenEADDRI”,而且端口是动态变化的。错误如下:Debuggerlisteningon[::]:25951Error:li</div>
                    </li>
                    <li><a href="/article/1833864459446218752.htm"
                           title="TypeScript---类型批注" target="_blank">TypeScript---类型批注</a>
                        <span class="text-muted">Anglie</span>

                        <div>TS通过类型批注提供静态类型,方便在编译时启动类型检查,这不是必须的,甚至可以被忽略,去使用js常规的动态类型。基本类型的批注是number,bool,string,弱类型或动态类型的结构可以是任意类型。将类型批注导出到一个单独的文件,方便使用类型已经被编译成为js的ts脚本的类型信息可用。批注可以为一个现有的js库声明。就像已经为node.js和jquery.js所做的那样。当没有给出类型时,T</div>
                    </li>
                    <li><a href="/article/1833780237662515200.htm"
                           title="经验笔记:Node.js 中的 process.nextTick" target="_blank">经验笔记:Node.js 中的 process.nextTick</a>
                        <span class="text-muted">漆黑的莫莫</span>
<a class="tag" taget="_blank" href="/search/%E7%AC%94%E8%AE%B0/1.htm">笔记</a><a class="tag" taget="_blank" href="/search/node.js/1.htm">node.js</a>
                        <div>Node.js中的process.nextTick经验笔记引言在Node.js环境中,process.nextTick是一个非常重要的API,用于在当前执行栈的所有同步操作完成后立即执行一个回调函数。这使得开发者能够在异步I/O操作和其他异步事件之前,执行一些需要立即响应的任务。本文将探讨process.nextTick的工作原理、使用场景以及注意事项。process.nextTick的工作机制N</div>
                    </li>
                    <li><a href="/article/1833756276375515136.htm"
                           title="FFCreator: 基于Node.js的高效视频制作库指南" target="_blank">FFCreator: 基于Node.js的高效视频制作库指南</a>
                        <span class="text-muted">江涛奎Stranger</span>

                        <div>FFCreator:基于Node.js的高效视频制作库指南FFCreator一个基于node.js的高速视频制作库Afastvideoprocessinglibrarybasedonnode.js项目地址:https://gitcode.com/gh_mirrors/ff/FFCreator1.项目介绍关于FFCreatorFFCreator是一款基于Node.js开发的高性能视频制作库,旨在简化</div>
                    </li>
                    <li><a href="/article/1833750894466920448.htm"
                           title="centos7安装node.js" target="_blank">centos7安装node.js</a>
                        <span class="text-muted">0981b16f19c7</span>

                        <div>安装step1:下载node.jswgethttps://npm.taobao.org/mirrors/node/v8.0.0/node-v8.0.0-linux-x64.tar.xzstep2:解压tar-xvfnode-v8.0.0-linux-x64.tar.xzstep3:配置环境变量,便于全局使用ln-s/usr/opt/node-v8.0.0-linux-x64/bin/node/us</div>
                    </li>
                    <li><a href="/article/1833734586845196288.htm"
                           title="解决“Module build failed (from ./node_modules/sass-loader/dist/cjs.js)“错误" target="_blank">解决“Module build failed (from ./node_modules/sass-loader/dist/cjs.js)“错误</a>
                        <span class="text-muted">Coderabo</span>
<a class="tag" taget="_blank" href="/search/sass/1.htm">sass</a><a class="tag" taget="_blank" href="/search/javascript/1.htm">javascript</a><a class="tag" taget="_blank" href="/search/rust/1.htm">rust</a>
                        <div>解决"Modulebuildfailed(from./node_modules/sass-loader/dist/cjs.js)"错误的技术指南如果你在使用Node.js和Sass时遇到了"Modulebuildfailed(from./node_modules/sass-loader/dist/cjs.js)"的错误,不要担心,这篇技术指南将详细介绍这个问题,并提供解决办法。首先,让我们深入了解</div>
                    </li>
                                <li><a href="/article/41.htm"
                                       title="html页面js获取参数值" target="_blank">html页面js获取参数值</a>
                                    <span class="text-muted">0624chenhong</span>
<a class="tag" taget="_blank" href="/search/html/1.htm">html</a>
                                    <div>1.js获取参数值js 
function GetQueryString(name) 
 { 
      var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); 
      var r = windo</div>
                                </li>
                                <li><a href="/article/168.htm"
                                       title="MongoDB 在多线程高并发下的问题" target="_blank">MongoDB 在多线程高并发下的问题</a>
                                    <span class="text-muted">BigCat2013</span>
<a class="tag" taget="_blank" href="/search/mongodb/1.htm">mongodb</a><a class="tag" taget="_blank" href="/search/DB/1.htm">DB</a><a class="tag" taget="_blank" href="/search/%E9%AB%98%E5%B9%B6%E5%8F%91/1.htm">高并发</a><a class="tag" taget="_blank" href="/search/%E9%87%8D%E5%A4%8D%E6%95%B0%E6%8D%AE/1.htm">重复数据</a>
                                    <div>最近项目用到 MongoDB , 主要是一些读取数据及改状态位的操作. 因为是结合了最近流行的 Storm进行大数据的分析处理,并将分析结果插入Vertica数据库,所以在多线程高并发的情境下, 会发现 Vertica 数据库中有部分重复的数据. 这到底是什么原因导致的呢?笔者开始也是一筹莫 展,重复去看 MongoDB 的 API , 终于有了新发现 : 
com.mongodb.DB 这个类有</div>
                                </li>
                                <li><a href="/article/295.htm"
                                       title="c++ 用类模版实现链表(c++语言程序设计第四版示例代码)" target="_blank">c++ 用类模版实现链表(c++语言程序设计第四版示例代码)</a>
                                    <span class="text-muted">CrazyMizzz</span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/C%2B%2B/1.htm">C++</a>
                                    <div>#include<iostream>
#include<cassert>
using namespace std;
template<class T>
class Node
{
private:
	Node<T> * next;
public:
	T data;                                    </div>
                                </li>
                                <li><a href="/article/422.htm"
                                       title="最近情况" target="_blank">最近情况</a>
                                    <span class="text-muted">麦田的设计者</span>
<a class="tag" taget="_blank" href="/search/%E6%84%9F%E6%85%A8/1.htm">感慨</a><a class="tag" taget="_blank" href="/search/%E8%80%83%E8%AF%95/1.htm">考试</a><a class="tag" taget="_blank" href="/search/%E7%94%9F%E6%B4%BB/1.htm">生活</a>
                                    <div>   在五月黄梅天的岁月里,一年两次的软考又要开始了。到目前为止,我已经考了多达三次的软考,最后的结果就是通过了初级考试(程序员)。人啊,就是不满足,考了初级就希望考中级,于是,这学期我就报考了中级,明天就要考试。感觉机会不大,期待奇迹发生吧。这个学期忙于练车,写项目,反正最后是一团糟。后天还要考试科目二。这个星期真的是很艰难的一周,希望能快点度过。 
  </div>
                                </li>
                                <li><a href="/article/549.htm"
                                       title="linux系统中用pkill踢出在线登录用户" target="_blank">linux系统中用pkill踢出在线登录用户</a>
                                    <span class="text-muted">被触发</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                                    <div>由于linux服务器允许多用户登录,公司很多人知道密码,工作造成一定的障碍所以需要有时踢出指定的用户 
1/#who   查出当前有那些终端登录(用 w 命令更详细) 
# who 
root     pts/0        2010-10-28 09:36 (192</div>
                                </li>
                                <li><a href="/article/676.htm"
                                       title="仿QQ聊天第二版" target="_blank">仿QQ聊天第二版</a>
                                    <span class="text-muted">肆无忌惮_</span>
<a class="tag" taget="_blank" href="/search/qq/1.htm">qq</a>
                                    <div>在第一版之上的改进内容: 
 第一版链接: 
http://479001499.iteye.com/admin/blogs/2100893 
  
用map存起来号码对应的聊天窗口对象,解决私聊的时候所有消息发到一个窗口的问题. 
增加ViewInfo类,这个是信息预览的窗口,如果是自己的信息,则可以进行编辑. 
  
信息修改后上传至服务器再告诉所有用户,自己的窗口</div>
                                </li>
                                <li><a href="/article/803.htm"
                                       title="java读取配置文件" target="_blank">java读取配置文件</a>
                                    <span class="text-muted">知了ing</span>

                                    <div>1,java读取.properties配置文件 
 
InputStream in;
		try {
			in = test.class.getClassLoader().getResourceAsStream("config/ipnetOracle.properties");//配置文件的路径
		    Properties p = new Properties()</div>
                                </li>
                                <li><a href="/article/930.htm"
                                       title="__attribute__ 你知多少?" target="_blank">__attribute__ 你知多少?</a>
                                    <span class="text-muted">矮蛋蛋</span>
<a class="tag" taget="_blank" href="/search/C%2B%2B/1.htm">C++</a><a class="tag" taget="_blank" href="/search/gcc/1.htm">gcc</a>
                                    <div>原文地址: 
http://www.cnblogs.com/astwish/p/3460618.html 
GNU C 的一大特色就是__attribute__ 机制。__attribute__ 可以设置函数属性(Function Attribute )、变量属性(Variable Attribute )和类型属性(Type Attribute )。 
 
__attribute__ 书写特征是:</div>
                                </li>
                                <li><a href="/article/1057.htm"
                                       title="jsoup使用笔记" target="_blank">jsoup使用笔记</a>
                                    <span class="text-muted">alleni123</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E7%88%AC%E8%99%AB/1.htm">爬虫</a><a class="tag" taget="_blank" href="/search/JSoup/1.htm">JSoup</a>
                                    <div><dependency>
	<groupId>org.jsoup</groupId>
	<artifactId>jsoup</artifactId>
	<version>1.7.3</version>
</dependency>
 
 
 
 
 
2014/08/28 
今天遇到这种形式, </div>
                                </li>
                                <li><a href="/article/1184.htm"
                                       title="JAVA中的集合 Collectio 和Map的简单使用及方法" target="_blank">JAVA中的集合 Collectio 和Map的简单使用及方法</a>
                                    <span class="text-muted">百合不是茶</span>
<a class="tag" taget="_blank" href="/search/list/1.htm">list</a><a class="tag" taget="_blank" href="/search/map/1.htm">map</a><a class="tag" taget="_blank" href="/search/set/1.htm">set</a>
                                    <div>         List ,set ,map的使用方法和区别 
java容器类类库的用途是保存对象,并将其分为两个概念: 
    Collection集合:一个独立的序列,这些序列都服从一条或多条规则;List必须按顺序保存元素  ,set不能重复元素;Queue按照排队规则来确定对象产生的顺序(通常与他们被插入的</div>
                                </li>
                                <li><a href="/article/1311.htm"
                                       title="杀LINUX的JOB进程" target="_blank">杀LINUX的JOB进程</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/unix/1.htm">unix</a>
                                    <div>今天发现数据库一个JOB一直在执行,都执行了好几个小时还在执行,所以想办法给删除掉 
  
系统环境: 
   ORACLE 10G 
   Linux操作系统 
  
操作步骤如下: 
第一步.查询出来那个job在运行,找个对应的SID字段 
select * from dba_jobs_running--找到job对应的sid 
&n</div>
                                </li>
                                <li><a href="/article/1438.htm"
                                       title="Spring AOP详解" target="_blank">Spring AOP详解</a>
                                    <span class="text-muted">bijian1013</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a>
                                    <div>        最近项目中遇到了以下几点需求,仔细思考之后,觉得采用AOP来解决。一方面是为了以更加灵活的方式来解决问题,另一方面是借此机会深入学习Spring AOP相关的内容。例如,以下需求不用AOP肯定也能解决,至于是否牵强附会,仁者见仁智者见智。 
1.对部分函数的调用进行日志记录,用于观察特定问题在运行过程中的函数调用</div>
                                </li>
                                <li><a href="/article/1565.htm"
                                       title="[Gson六]Gson类型适配器(TypeAdapter)" target="_blank">[Gson六]Gson类型适配器(TypeAdapter)</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/Adapter/1.htm">Adapter</a>
                                    <div>TypeAdapter的使用动机 
 Gson在序列化和反序列化时,默认情况下,是按照POJO类的字段属性名和JSON串键进行一一映射匹配,然后把JSON串的键对应的值转换成POJO相同字段对应的值,反之亦然,在这个过程中有一个JSON串Key对应的Value和对象之间如何转换(序列化/反序列化)的问题。 
  
以Date为例,在序列化和反序列化时,Gson默认使用java.</div>
                                </li>
                                <li><a href="/article/1692.htm"
                                       title="【spark八十七】给定Driver Program, 如何判断哪些代码在Driver运行,哪些代码在Worker上执行" target="_blank">【spark八十七】给定Driver Program, 如何判断哪些代码在Driver运行,哪些代码在Worker上执行</a>
                                    <span class="text-muted">bit1129</span>
<a class="tag" taget="_blank" href="/search/driver/1.htm">driver</a>
                                    <div>Driver Program是用户编写的提交给Spark集群执行的application,它包含两部分 
 
 作为驱动: Driver与Master、Worker协作完成application进程的启动、DAG划分、计算任务封装、计算任务分发到各个计算节点(Worker)、计算资源的分配等。 
 计算逻辑本身,当计算任务在Worker执行时,执行计算逻辑完成application的计算任务 
 </div>
                                </li>
                                <li><a href="/article/1819.htm"
                                       title="nginx 经验总结" target="_blank">nginx 经验总结</a>
                                    <span class="text-muted">ronin47</span>
<a class="tag" taget="_blank" href="/search/nginx+%E6%80%BB%E7%BB%93/1.htm">nginx 总结</a>
                                    <div>   深感nginx的强大,只学了皮毛,把学下的记录。 
   获取Header 信息,一般是以$http_XX(XX是小写) 
           获取body,通过接口,再展开,根据K取V 
   获取uri,以$arg_XX 
     &n</div>
                                </li>
                                <li><a href="/article/1946.htm"
                                       title="轩辕互动-1.求三个整数中第二大的数2.整型数组的平衡点" target="_blank">轩辕互动-1.求三个整数中第二大的数2.整型数组的平衡点</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E7%BB%84/1.htm">数组</a>
                                    <div>
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class ExoWeb {

	public static void main(String[] args) {
		ExoWeb ew=new ExoWeb();
		
		System.out.pri</div>
                                </li>
                                <li><a href="/article/2073.htm"
                                       title="Netty源码学习-Java-NIO-Reactor" target="_blank">Netty源码学习-Java-NIO-Reactor</a>
                                    <span class="text-muted">bylijinnan</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%A4%9A%E7%BA%BF%E7%A8%8B/1.htm">多线程</a><a class="tag" taget="_blank" href="/search/netty/1.htm">netty</a>
                                    <div>Netty里面采用了NIO-based Reactor Pattern 
了解这个模式对学习Netty非常有帮助 
 
参考以下两篇文章: 
 
http://jeewanthad.blogspot.com/2013/02/reactor-pattern-explained-part-1.html 
 
http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf 
</div>
                                </li>
                                <li><a href="/article/2200.htm"
                                       title="AOP通俗理解" target="_blank">AOP通俗理解</a>
                                    <span class="text-muted">cngolon</span>
<a class="tag" taget="_blank" href="/search/spring/1.htm">spring</a><a class="tag" taget="_blank" href="/search/AOP/1.htm">AOP</a>
                                    <div>1.我所知道的aop     初看aop,上来就是一大堆术语,而且还有个拉风的名字,面向切面编程,都说是OOP的一种有益补充等等。一下子让你不知所措,心想着:怪不得很多人都和 我说aop多难多难。当我看进去以后,我才发现:它就是一些java基础上的朴实无华的应用,包括ioc,包括许许多多这样的名词,都是万变不离其宗而 已。 2.为什么用aop&nb</div>
                                </li>
                                <li><a href="/article/2327.htm"
                                       title="cursor variable 实例" target="_blank">cursor variable 实例</a>
                                    <span class="text-muted">ctrain</span>
<a class="tag" taget="_blank" href="/search/variable/1.htm">variable</a>
                                    <div>
create or replace procedure proc_test01
as 
type emp_row is record(
empno emp.empno%type,
ename emp.ename%type,
job emp.job%type,
mgr emp.mgr%type,
hiberdate emp.hiredate%type,
sal emp.sal%t</div>
                                </li>
                                <li><a href="/article/2454.htm"
                                       title="shell报bash: service: command not found解决方法" target="_blank">shell报bash: service: command not found解决方法</a>
                                    <span class="text-muted">daizj</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/shell/1.htm">shell</a><a class="tag" taget="_blank" href="/search/service/1.htm">service</a><a class="tag" taget="_blank" href="/search/jps/1.htm">jps</a>
                                    <div>今天在执行一个脚本时,本来是想在脚本中启动hdfs和hive等程序,可以在执行到service hive-server start等启动服务的命令时会报错,最终解决方法记录一下: 
  
脚本报错如下: 
./olap_quick_intall.sh: line 57: service: command not found 
./olap_quick_intall.sh: line 59</div>
                                </li>
                                <li><a href="/article/2581.htm"
                                       title="40个迹象表明你还是PHP菜鸟" target="_blank">40个迹象表明你还是PHP菜鸟</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/1.htm">设计模式</a><a class="tag" taget="_blank" href="/search/PHP/1.htm">PHP</a><a class="tag" taget="_blank" href="/search/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/1.htm">正则表达式</a><a class="tag" taget="_blank" href="/search/oop/1.htm">oop</a>
                                    <div>你是PHP菜鸟,如果你:1. 不会利用如phpDoc 这样的工具来恰当地注释你的代码2. 对优秀的集成开发环境如Zend Studio 或Eclipse PDT 视而不见3. 从未用过任何形式的版本控制系统,如Subclipse4. 不采用某种编码与命名标准 ,以及通用约定,不能在项目开发周期里贯彻落实5. 不使用统一开发方式6. 不转换(或)也不验证某些输入或SQL查询串(译注:参考PHP相关函</div>
                                </li>
                                <li><a href="/article/2708.htm"
                                       title="Android逐帧动画的实现" target="_blank">Android逐帧动画的实现</a>
                                    <span class="text-muted">dcj3sjt126com</span>
<a class="tag" taget="_blank" href="/search/android/1.htm">android</a>
                                    <div>一、代码实现: 
private ImageView iv;
	private AnimationDrawable ad;
	
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout</div>
                                </li>
                                <li><a href="/article/2835.htm"
                                       title="java远程调用linux的命令或者脚本" target="_blank">java远程调用linux的命令或者脚本</a>
                                    <span class="text-muted">eksliang</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/ganymed-ssh2/1.htm">ganymed-ssh2</a>
                                    <div>转载请出自出处:
http://eksliang.iteye.com/blog/2105862  
    
   Java通过SSH2协议执行远程Shell脚本(ganymed-ssh2-build210.jar)  
 使用步骤如下: 
1.导包 
官网下载: 
http://www.ganymed.ethz.ch/ssh2/ 
ma</div>
                                </li>
                                <li><a href="/article/2962.htm"
                                       title="adb端口被占用问题" target="_blank">adb端口被占用问题</a>
                                    <span class="text-muted">gqdy365</span>
<a class="tag" taget="_blank" href="/search/adb/1.htm">adb</a>
                                    <div>最近重新安装的电脑,配置了新环境,老是出现: 
 
 

 adb server is out of date.  killing...  
    ADB server didn't ACK  
    * failed to start daemon *  
 
百度了一下,说是端口被占用,我开个eclipse,然后打开cmd,就提示这个,很烦人。 
 
一个比较彻底的解决办法就是修改</div>
                                </li>
                                <li><a href="/article/3089.htm"
                                       title="ASP.NET使用FileUpload上传文件" target="_blank">ASP.NET使用FileUpload上传文件</a>
                                    <span class="text-muted">hvt</span>
<a class="tag" taget="_blank" href="/search/.net/1.htm">.net</a><a class="tag" taget="_blank" href="/search/C%23/1.htm">C#</a><a class="tag" taget="_blank" href="/search/hovertree/1.htm">hovertree</a><a class="tag" taget="_blank" href="/search/asp.net/1.htm">asp.net</a><a class="tag" taget="_blank" href="/search/webform/1.htm">webform</a>
                                    <div>前台代码: 
<asp:FileUpload ID="fuKeleyi" runat="server" />
<asp:Button ID="BtnUp" runat="server" onclick="BtnUp_Click" Text="上 传" /></div>
                                </li>
                                <li><a href="/article/3216.htm"
                                       title="代码之谜(四)- 浮点数(从惊讶到思考)" target="_blank">代码之谜(四)- 浮点数(从惊讶到思考)</a>
                                    <span class="text-muted">justjavac</span>
<a class="tag" taget="_blank" href="/search/%E6%B5%AE%E7%82%B9%E6%95%B0/1.htm">浮点数</a><a class="tag" taget="_blank" href="/search/%E7%B2%BE%E5%BA%A6/1.htm">精度</a><a class="tag" taget="_blank" href="/search/%E4%BB%A3%E7%A0%81%E4%B9%8B%E8%B0%9C/1.htm">代码之谜</a><a class="tag" taget="_blank" href="/search/IEEE/1.htm">IEEE</a>
                                    <div>在『代码之谜』系列的前几篇文章中,很多次出现了浮点数。 浮点数在很多编程语言中被称为简单数据类型,其实,浮点数比起那些复杂数据类型(比如字符串)来说, 一点都不简单。 
单单是说明 IEEE浮点数 就可以写一本书了,我将用几篇博文来简单的说说我所理解的浮点数,算是抛砖引玉吧。 一次面试 
记得多年前我招聘 Java 程序员时的一次关于浮点数、二分法、编码的面试, 多年以后,他已经称为了一名很出色的</div>
                                </li>
                                <li><a href="/article/3343.htm"
                                       title="数据结构随记_1" target="_blank">数据结构随记_1</a>
                                    <span class="text-muted">lx.asymmetric</span>
<a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/1.htm">数据结构</a><a class="tag" taget="_blank" href="/search/%E7%AC%94%E8%AE%B0/1.htm">笔记</a>
                                    <div>第一章 
  1.数据结构包括数据的
逻辑结构、数据的物理/存储结构和数据的逻辑关系这三个方面的内容。 2.数据的存储结构可用四种基本的存储方法表示,它们分别是
顺序存储、链式存储 、索引存储 和 散列存储。 3.数据运算最常用的有五种,分别是
 查找/检索、排序、插入、删除、修改。 4.算法主要有以下五个特性: 
输入、输出、可行性、确定性和有穷性。 5.算法分析的</div>
                                </li>
                                <li><a href="/article/3470.htm"
                                       title="linux的会话和进程组" target="_blank">linux的会话和进程组</a>
                                    <span class="text-muted">网络接口</span>
<a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a>
                                    <div>会话: 一个或多个进程组。起于用户登录,终止于用户退出。此期间所有进程都属于这个会话期。会话首进程:调用setsid创建会话的进程1.规定组长进程不能调用setsid,因为调用setsid后,调用进程会成为新的进程组的组长进程.如何保证? 先调用fork,然后终止父进程,此时由于子进程的进程组ID为父进程的进程组ID,而子进程的ID是重新分配的,所以保证子进程不会是进程组长,从而子进程可以调用se</div>
                                </li>
                                <li><a href="/article/3597.htm"
                                       title="二维数组 元素的连续求解" target="_blank">二维数组 元素的连续求解</a>
                                    <span class="text-muted">1140566087</span>
<a class="tag" taget="_blank" href="/search/%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84/1.htm">二维数组</a><a class="tag" taget="_blank" href="/search/ACM/1.htm">ACM</a>
                                    <div>import java.util.HashMap;




public class Title {
	public static void main(String[] args){
		f();
	}

	// 二位数组的应用
	//12、二维数组中,哪一行或哪一列的连续存放的0的个数最多,是几个0。注意,是“连续”。
	public static void f(){
</div>
                                </li>
                                <li><a href="/article/3724.htm"
                                       title="也谈什么时候Java比C++快" target="_blank">也谈什么时候Java比C++快</a>
                                    <span class="text-muted">windshome</span>
<a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/C%2B%2B/1.htm">C++</a>
                                    <div>  
刚打开iteye就看到这个标题“Java什么时候比C++快”,觉得很好笑。 
  
你要比,就比同等水平的基础上的相比,笨蛋写得C代码和C++代码,去和高手写的Java代码比效率,有什么意义呢? 
  
我是写密码算法的,深刻知道算法C和C++实现和Java实现之间的效率差,甚至也比对过C代码和汇编代码的效率差,计算机是个死的东西,再怎么优化,Java也就是和C</div>
                                </li>
                </ul>
            </div>
        </div>
    </div>

<div>
    <div class="container">
        <div class="indexes">
            <strong>按字母分类:</strong>
            <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a
                href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a
                href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a
                href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a
                href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a
                href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a
                href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a
                href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a
                href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a>
        </div>
    </div>
</div>
<footer id="footer" class="mb30 mt30">
    <div class="container">
        <div class="footBglm">
            <a target="_blank" href="/">首页</a> -
            <a target="_blank" href="/custom/about.htm">关于我们</a> -
            <a target="_blank" href="/search/Java/1.htm">站内搜索</a> -
            <a target="_blank" href="/sitemap.txt">Sitemap</a> -
            <a target="_blank" href="/custom/delete.htm">侵权投诉</a>
        </div>
        <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved.
<!--            <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>-->
        </div>
    </div>
</footer>
<!-- 代码高亮 -->
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script>
<script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script>
<link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script>





</body>

</html>