浅谈一下Socket

前言

大家好,我是阿语

之前的小工具,我自己也在逐渐添加新的功能

今天突发奇想,想写一个http下载的功能,所以就自己实际动手开始写了

既然提到,下载,上传等网络传输,那就必定离不开一个名词,Socket

什么是Socket?

socket就是一个网络传输协议的套接字

TCP 一般分为,服务器(监听端),以及客户端(请求端)

UDP 一般来说呢,监听端与请求端,都是同一个端口 比如绑定一个udp(3223) 那他的发送端口与接收端口都是3223

TCP:为了确保数据的准确以及连贯性,会进行三次握手,维持长连接,检查是否丢包等方式保护数据的完整性

因为提及的http,而http又是socket tcp的上层协议,所以今天主要就说一说HTTP协议

如何链接http服务器,并发送正确的参数?

HTTP协议

GET / HTTP/1.1
Host: www.baidu.com

这就是一个http协议头,说白了,网络协议没有那么难懂,就是一些标志性的参数,告诉服务器,我是什么类型的协议,我想要什么,服务器看完就知道你想要什么,就会给你返回什么.但是如果服务器看不懂,那他就只能报错了

以上,就是请求百度的http协议头,当然是做了删减的,一般还会带有其他的参数,其他的参数今天就不讲了

GET/POST请求的不同

第一行 GET / HTTP/1.1

GET 顾名思义,就是GET请求方式,http的请求方式有很多种,但是最常用的就是GET/POST两种请求方式

如果第一行是POST / HTTP/1.1 那就代表着这个请求,是POST请求

GET请求,一般会在/后边直接带上参数,比如

GET /send.php?user=123123&pass=123123 HTTP/1.1
Host: www.baidu.com

请求的URL地址 直接带上参数,比如user代表账号123123 pass代码密码123123

这种请求方式是明文,不安全,所以除了访问以及公开的api接口,私密性的数据,都会采用post方式进行请求

那同样是一个功能 post方式又是如何请求的呢?

请看下边的协议头

POST /send.php HTTP/1.1
Host: www.baidu.com

user=123123&pass=123123

这就是post请求协议,他将要发送的数据,放在了下边,虽然只是小小的改变,但是你在浏览器的url中,就看不到带入的参数了

既然简单的了解了,http协议,那我们就动手写一个请求的socket出来吧

本文语言采用c++ 编译平台arch64 Aidlux

没有C++环境的,先安装个c++吧
apt install g++
//先创建一个类吧,用于封装请求接口
class Requ{
    public:
        Requ(string _ip,int _port);
        int download(string _url,string _head,string _data,string path,bool type);    //下载文件 true为post,false为get
    string ret(string _url, string _data,string _head,bool type);                 //请求 true为post,false为get
private:
    string _ip; 
    int _port;
    int connect_s();

};

这个类有两个公开的函数,以及一个构造函数

构造函数,用于接收 请求的ip,以及端口

int download(

``` 请求的url

附加的协议头

请求的数据

保存的文件路径,以及文件名

是否为post请求方式

<p>)返回下载的文件长度 单位(byte)</p>
<p>string ret()这个函数与上边类似,只是没有了保存的文件地址,而是把数据用string类型返回</p>
<h4>先实现构造函数吧:</h4>
<pre><code class="language-cpp">//获得参数
Requ::Requ(string ip,int port){
    _ip = ip;           //获取ip地址
    _port = port;       //获取链接sock端口号
}
</code></pre>
<p>获取到需要链接的ip以及端口,保存到类中的变量中</p>
<h4>接下来实现链接</h4>
<pre><code class="language-cpp">//与服务器建立链接
int Requ::connect_s(){
    int sockfd, numbytes; 
    struct sockaddr_in server_addr; 

    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { 
        perror(&quot;socket&quot;); 
        return -1;
    }

    server_addr.sin_family = AF_INET; 
    server_addr.sin_port = htons(_port); 
    server_addr.sin_addr.s_addr = inet_addr(_ip.c_str()); 
    bzero(&amp;(server_addr.sin_zero),sizeof(server_addr.sin_zero)); 

    if (connect(sockfd, (struct sockaddr *)&amp;server_addr,sizeof(struct sockaddr_in)) == -1){
         perror(&quot;connect error&quot;); 
         return -1;
         //链接失败返回-1
    }

    return sockfd;  //返回socket进程号
}
</code></pre>
<p>这个函数,主要用于,链接服务器,并返回对应的进行号,给后边的发送和接收做铺垫</p>
<h4>实现下载的请求</h4>
<pre><code class="language-cpp">//下载文件
int Requ::download(string _url,string _head,string _data,string path,bool type) { 
    int sockfd = connect_s();
    struct timeval tv = {3, 0};
    if(sockfd == -1){
        cout &lt;&lt; (&quot;文件下载失败&quot;) &lt;&lt; endl;
        return -1;
    }

    /*判断请求方式,true为POST  false为GET*/
    string head = &quot;GET &quot;;
    if(type == true){
        head = &quot;POST &quot;;
    }


    /* 对http协议头进行添加 */
    head += _url;
    head += &quot; HTTP/1.1\r\n&quot;;
    head += _head;
    head += &quot;\r\n\r\n&quot;;
    head += _data;
  
    /* 添加完参数,发送给服务器,等待返回数据 */
    send(sockfd, head.c_str(),strlen(head.c_str()),0);


    int len = 0;                                                                //已下载的文件总长                                                              //获取http协议头里的leng长度
    int Times = 0;                                                         //判断是否为首次循环       其实这样写是有问题的,一旦网络环境极差,一次读不到1kb的话,就会出现bug,但是我懒得修了....
    string p = &quot;touch &quot;;                                                        //使用System 操作linux命令,创建一个文件   文件名就是传入进来的文件名称
    p += path;                                                                  //将 system命令连接起来  编程了 类似   touch /home/1.png
    system(p.c_str());                                                          //执行 system命令
	ofstream f(path,ios::out|ios::binary);                                      //使用追加 且 二进制的方式打开刚刚创建好的文件 准备写入

	fd_set fds;
    struct timeval timeout = {0,3};

    bool t = true;
    while(t){
        //判断是否还有剩余的字符
        FD_ZERO(&amp;fds);
        FD_SET(sockfd, &amp;fds);
        timeout.tv_sec = 1;
        timeout.tv_usec = 0;

        switch(select(sockfd+1,&amp;fds,NULL,NULL,&amp;timeout)){
            case -1:
                cout &lt;&lt; &quot;socke流错误&quot; &lt;&lt; endl;
                break;
            case 0:
                t = false;
                break;
            default:

                int te = -1;
                char buf[MAXDATASIZE] = {0};

                te = recv(sockfd, buf, MAXDATASIZE-1, 0);
                if(Times &gt; 0){
                     f.write(buf,te);
                }
                len += te;

                if(Times == 0){
                    string cont_len = buf;                                                     //准备处理协议结尾,寻找文件头,并对协议部分的大小做计算,切除协议部分,只留下文件本体,准备储存
                    cont_len = cont_len.substr(0,cont_len.find(&quot;\r\n\r\n&quot;)+4);
                    len = te - strlen(cont_len.c_str());
                    char t[len];                                                        //临时缓冲,从字符串中提出本次接受的文件本体,并写入到文件内
                    memcpy(t,buf+strlen(cont_len.c_str()),len);                       
                    f.write(t,len);                                                     //写入成功 修改标识,本代码块只运行一次,主要就是为了取出文件长度,和分割出文件头本体
                }

                Times++;
        }
      
    }

    cout &lt;&lt; &quot;接受总长:&quot; &lt;&lt; len &lt;&lt; endl;                                         //查看文件的总长与接受的总长是否一致
    f.close();
    close(sockfd);
    return len;
}
</code></pre>
<h4>请求的实现,就快成功啦</h4>
<pre><code class="language-cpp">
//数据请求,GET POST
//同上,原理差不多,只是把接受到的char* 不写入到文件,而是追加到string类型中,最后统一返回string
string Requ::ret(string _url,string _head,string _data,bool type) { 
    int sockfd = connect_s();
    if(sockfd == -1){
        return &quot;error connect&quot;;
    }
    string data;
    string head = &quot;GET &quot;;
    if(type == true){
        head = &quot;POST &quot;;
    }
    head += _url;
    head += &quot; HTTP/1.1\r\n&quot;;
    head += _head;
    head += &quot;\r\n\r\n&quot;;
    head += _data;
  
    send(sockfd, head.c_str(),strlen(head.c_str()),0);
    int len = 0;
    int Times = 0;

    fd_set fds;
    struct timeval timeout = {0,3};

    bool t = true;
    while(t){
        //判断是否还有剩余的字符
        FD_ZERO(&amp;fds);
        FD_SET(sockfd, &amp;fds);
        timeout.tv_sec = 1;
        timeout.tv_usec = 0;

        switch(select(sockfd+1,&amp;fds,NULL,NULL,&amp;timeout)){
            case -1:
                cout &lt;&lt; &quot;socke流错误&quot; &lt;&lt; endl;
                break;
            case 0:
                t = false;
                break;
            default:

                int te = -1;
                char buf[MAXDATASIZE] = {0};

                te = recv(sockfd, buf, MAXDATASIZE-1, 0);
                if(Times &gt; 0){
                     data += buf;
                }
                len += te;

                if(Times == 0){
                    //计算结束头字节大小
                    string cont_len = buf;
                    cont_len = cont_len.substr(cont_len.find(&quot;\r\n\r\n&quot;)+4);
                    data += cont_len;
                }

                Times++;
        }
      
    }
    close(sockfd);
    return data;
}
</code></pre>
<p>使用也是很简单</p>
<pre><code class="language-cpp">#include &quot;requ.h&quot;
using namespace std;

int main(){
	Requ rt(163.177.151.110,80);	//请求一下百度的http文件源码吧
	string buf = rt.ret(&quot;/&quot;,&quot;Host: www.baidu.com&quot;,&quot;&quot;,false);
	cout &lt;&lt; buf &lt;&lt; endl;
	return 0;
}
</code></pre>
<p>就会输出</p>
<pre><code class="language-http">&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge,chrome=1&quot;&gt;&lt;meta content=&quot;always&quot; name=&quot;referrer&quot;&gt;&lt;meta name=&quot;description&quot; content=&quot;全球领先的中文搜索引擎、致力于让网民更便捷地获取信息,找到所求。百度超过千亿的中文网页数据库,可以瞬间找到相关的搜索结果。&quot;&gt;&lt;link rel=&quot;shortcut icon&quot; href=&quot;//www.baidu.com/favicon.ico&quot; type=&quot;image/x-icon&quot;&gt;&lt;link rel=&quot;search&quot; type=&quot;application/opensearchdescription+xml&quot; href=&quot;//www.baidu.com/content-search.xml&quot; title=&quot;百度搜索&quot;&gt;&lt;title&gt;百度一下,你就知道&lt;/title&gt;&lt;style type=&quot;text/css&quot;&gt;body{margin:0;padding:0;text-align:center;background:#fff;height:100%}html{overflow-y:auto;color:#000;overflow:-moz-scrollbars;height:100%}body,input{font-size:12px;font-family:&quot;PingFang SC&quot;,Arial,&quot;Microsoft YaHei&quot;,sans-serif}a{text-decoration:none}a:hover{text-decoration:underline}img{border:0;-ms-interpolation-mode:bicubic}input{font-size:100%;border:0}body,form{position:relative;z-index:0}#wrapper{height:100%}#head_wrapper.s-ps-islite{padding-bottom:370px}#head_wrapper.s-ps-islite .s_form{position:relative;z-index:1}#head_wrapper.s-ps-islite .fm{position:absolute;bottom:0}#head_wrapper.s-ps-islite .s-p-top{position:absolute;bottom:40px;width:100%;height:181px}#head_wrapper.s-ps-islite #s_lg_img{position:static;margin:33px auto 0 auto;left:50%}#form{z-index:1}.s_form_wrapper{height:100%}#lh{margin:16px 0 5px;word-spacing:3px}.c-font-normal{font:13px/23px Arial,sans-serif}.c-color-t{color:#222}.c-btn,.c-btn:visited{color:#333!important}.c-btn{display:inline-block;overflow:hidden;font-family:inherit;font-weight:400;text-align:center;vertical-align:middle;outline:0;border:0;height:30px;width:80px;line-height:30px;font-size:13px;border-radius:6px;padding:0;background-color:#f5f5f6;cursor:pointer}.c-btn:hover{background-color:#315efb;color:#fff!important}a.c-btn{text-decoration:none}.c-btn-mini{height:24px;width:48px;line-height:24px}.c-btn-primary,.c-btn-primary:visited{color:#fff!important}.c-btn-primary{background-color:#4e6ef2}.c-btn-primary:hover{background-color:#315efb}a:active{color:#f60}#wrapper{position:relative;min-height:100%}#head{padding-bottom:100px;text-align:center}#wrapper{min-width:1250px;height:100%;min-height:600px}#head{position:relative;padding-bottom:0;height:100%;min-height:600px}.s_form_wrapper{height:100%}.quickdelete-wrap{position:relative}.tools{position:absolute;right:-75px}.s-isindex-wrap{position:relative}#head_wrapper.head_wrapper{width:auto}#head_wrapper{position:relative;height:40%;min-height:314px;max-height:510px;width:1000px;margin:0 auto}#head_wrapper .s-p-top{height:60%;min-height:185px;max-height:310px;position:relative;z-index:0;text-align:center}#head_wrapper input{outline:0;-webkit-appearance:none}#head_wrapper .s_btn_wr,#head_wrapper .s_ipt_wr{display:inline-block;zoom:1;background:0 0;vertical-align:top}#head_wrapper .s_ipt_wr{position:relative;width:546px}#head_wrapper .s_btn_wr{width:108px;height:44px;position:relative;z-index:2}#head_wrapper .s_ipt_wr:hover #kw{border-color:#a7aab5}#head_wrapper #kw{width:512px;height:16px;padding:12px 16px;font-size:16px;margin:0;vertical-align:top;outline:0;box-shadow:none;border-radius:10px 0 0 10px;border:2px solid #c4c7ce;background:#fff;color:#222;overflow:hidden;box-sizing:content-box}#head_wrapper #kw:focus{border-color:#4e6ef2!important;opacity:1}#head_wrapper .s_form{width:654px;height:100%;margin:0 auto;text-align:left;z-index:100}#head_wrapper .s_btn{cursor:pointer;width:108px;height:44px;line-height:45px;padding:0;background:0 0;background-color:#4e6ef2;border-radius:0 10px 10px 0;font-size:17px;color:#fff;box-shadow:none;font-weight:400;border:none;outline:0}#head_wrapper .s_btn:hover{background-color:#4662d9}#head_wrapper .s_btn:active{background-color:#4662d9}#head_wrapper .quickdelete-wrap{position:relative}#s_top_wrap{position:absolute;z-index:99;min-width:1000px;width:100%}.s-top-left{position:absolute;left:0;top:0;z-index:100;height:60px;padding-left:24px}.s-top-left .mnav{margin-right:31px;margin-top:19px;display:inline-block;position:relative}.s-top-left .mnav:hover .s-bri,.s-top-left a:hover{color:#315efb;text-decoration:none}.s-top-left .s-top-more-btn{padding-bottom:19px}.s-top-left .s-top-more-btn:hover .s-top-more{display:block}.s-top-right{position:absolute;right:0;top:0;z-index:100;height:60px;padding-right:24px}.s-top-right .s-top-right-text{margin-left:32px;margin-top:19px;display:inline-block;position:relative;vertical-align:top;cursor:pointer}.s-top-right .s-top-right-text:hover{color:#315efb}.s-top-right .s-top-login-btn{display:inline-block;margin-top:18px;margin-left:32px;font-size:13px}.s-top-right a:hover{text-decoration:none}#bottom_layer{width:100%;position:fixed;z-index:302;bottom:0;left:0;height:39px;padding-top:1px;overflow:hidden;zoom:1;margin:0;line-height:39px;background:#fff}#bottom_layer .lh{display:inline;margin-right:20px}#bottom_layer .lh:last-child{margin-left:-2px;margin-right:0}#bottom_layer .lh.activity{font-weight:700;text-decoration:underline}#bottom_layer a{font-size:12px;text-decoration:none}#bottom_layer .text-color{color:#bbb}#bottom_layer a:hover{color:#222}#bottom_layer .s-bottom-layer-content{text-align:center}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;div id=&quot;wrapper&quot; class=&quot;wrapper_new&quot;&gt;&lt;div id=&quot;head&quot;&gt;&lt;div id=&quot;s-top-left&quot; class=&quot;s-top-left s-isindex-wrap&quot;&gt;&lt;a href=&quot;//news.baidu.com/&quot; target=&quot;_blank&quot; class=&quot;mnav c-font-normal c-color-t&quot;&gt;新闻&lt;/a&gt;&lt;a href=&quot;//www.hao123.com/&quot; target=&quot;_blank&quot; class=&quot;mnav c-font-normal c-color-t&quot;&gt;hao123&lt;/a&gt;&lt;a href=&quot;//map.baidu.com/&quot; target=&quot;_blank&quot; class=&quot;mnav c-font-normal c-color-t&quot;&gt;地图&lt;/a&gt;&lt;a href=&quot;//live.baidu.com/&quot; target=&quot;_blank&quot; class=&quot;mnav c-font-normal c-color-t&quot;&gt;直播&lt;/a&gt;&lt;a href=&quot;//haokan.baidu.com/?sfrom=baidu-top&quot; target=&quot;_blank&quot; class=&quot;mnav c-font-normal c-color-t&quot;&gt;视频&lt;/a&gt;&lt;a href=&quot;//tieba.baidu.com/&quot; target=&quot;_blank&quot; class=&quot;mnav c-font-normal c-color-t&quot;&gt;贴吧&lt;/a&gt;&lt;a href=&quot;//xueshu.baidu.com/&quot; target=&quot;_blank&quot; class=&quot;mnav c-font-normal c-color-t&quot;&gt;学术&lt;/a&gt;&lt;div class=&quot;mnav s-top-more-btn&quot;&gt;&lt;a href=&quot;//www.baidu.com/more/&quot; name=&quot;tj_briicon&quot; class=&quot;s-bri c-font-normal c-color-t&quot; target=&quot;_blank&quot;&gt;更多&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div id=&quot;u1&quot; class=&quot;s-top-right s-isindex-wrap&quot;&gt;&lt;a class=&quot;s-top-login-btn c-btn c-btn-primary c-btn-mini lb&quot; style=&quot;position:relative;overflow:visible&quot; name=&quot;tj_login&quot; href=&quot;//www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1&quot;&gt;登录&lt;/a&gt;&lt;/div&gt;&lt;div id=&quot;head_wrapper&quot; class=&quot;head_wrapper s-isindex-wrap s-ps-islite&quot;&gt;&lt;div class=&quot;s_form&quot;&gt;&lt;div class=&quot;s_form_wrapper&quot;&gt;&lt;div id=&quot;lg&quot; class=&quot;s-p-top&quot;&gt;&lt;img hidefocus=&quot;true&quot; id=&quot;s_lg_img&quot; class=&quot;index-logo-src&quot; src=&quot;//www.baidu.com/img/flexible/logo/pc/index.png&quot; width=&quot;270&quot; height=&quot;129&quot; usemap=&quot;#mp&quot;&gt;&lt;map name=&quot;mp&quot;&gt;&lt;area style=&quot;outline:0&quot; hidefocus=&quot;true&quot; shape=&quot;rect&quot; coords=&quot;0,0,270,129&quot; href=&quot;//www.baidu.com/s?wd=%E7%99%BE%E5%BA%A6%E7%83%AD%E6%90%9C&amp;sa=ire_dl_gh_logo_texing&amp;rsv_dl=igh_logo_pcs&quot; target=&quot;_blank&quot; title=&quot;点击一下,了解更多&quot;&gt;&lt;/map&gt;&lt;/div&gt;&lt;a href=&quot;//www.baidu.com/&quot; id=&quot;result_logo&quot;&gt;&lt;/a&gt;&lt;form id=&quot;form&quot; name=&quot;f&quot; action=&quot;//www.baidu.com/s&quot; class=&quot;fm&quot;&gt;&lt;input type=&quot;hidden&quot; name=&quot;ie&quot; value=&quot;utf-8&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;f&quot; value=&quot;8&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;rsv_bp&quot; value=&quot;1&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;rsv_idx&quot; value=&quot;1&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;ch&quot; value=&quot;&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;tn&quot; value=&quot;baidu&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;bar&quot; value=&quot;&quot;&gt; &lt;span class=&quot;s_ipt_wr quickdelete-wrap&quot;&gt;&lt;input id=&quot;kw&quot; name=&quot;wd&quot; class=&quot;s_ipt&quot; value=&quot;&quot; maxlength=&quot;255&quot; autocomplete=&quot;off&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s_btn_wr&quot;&gt;&lt;input type=&quot;submit&quot; id=&quot;su&quot; value=&quot;百度一下&quot; class=&quot;bg s_btn&quot;&gt; &lt;/span&gt;&lt;input type=&quot;hidden&quot; name=&quot;rn&quot; value=&quot;&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;fenlei&quot; value=&quot;256&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;oq&quot; value=&quot;&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;rsv_pq&quot; value=&quot;b9ff093e0000e419&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;rsv_t&quot; value=&quot;3635FYbdbC8tlWmudZmYaUnaucNe+RzTzNEGqg/JuniQU10WL5mtMQehIrU&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;rqlang&quot; value=&quot;cn&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;rsv_enter&quot; value=&quot;1&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;rsv_dl&quot; value=&quot;ib&quot;&gt;&lt;/form&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div id=&quot;bottom_layer&quot; class=&quot;s-bottom-layer s-isindex-wrap&quot;&gt;&lt;div class=&quot;s-bottom-layer-content&quot;&gt;&lt;p class=&quot;lh&quot;&gt;&lt;a class=&quot;text-color&quot; href=&quot;//home.baidu.com/&quot; target=&quot;_blank&quot;&gt;关于百度&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;a class=&quot;text-color&quot; href=&quot;//ir.baidu.com/&quot; target=&quot;_blank&quot;&gt;About Baidu&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;a class=&quot;text-color&quot; href=&quot;//www.baidu.com/duty&quot; target=&quot;_blank&quot;&gt;使用百度前必读&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;a class=&quot;text-color&quot; href=&quot;//help.baidu.com/&quot; target=&quot;_blank&quot;&gt;帮助中心&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;a class=&quot;text-color&quot; href=&quot;//www.beian.gov.cn/portal/registerSystemInfo?recordcode=11000002000001&quot; target=&quot;_blank&quot;&gt;京公网安备11000002000001号&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;a class=&quot;text-color&quot; href=&quot;//beian.miit.gov.cn/&quot; target=&quot;_blank&quot;&gt;京ICP证030173号&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;span id=&quot;year&quot; class=&quot;text-color&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;span class=&quot;text-color&quot;&gt;互联网药品信息服务资格证书 (京)-经营性-2017-0020&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;lh&quot;&gt;&lt;a class=&quot;text-color&quot; href=&quot;//www.baidu.com/licence/&quot; target=&quot;_blank&quot;&gt;信息网络传播视听节目许可证 0110516&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;var date=new Date,year=date.getFullYear();document.getElementById(&quot;year&quot;).innerText=&quot;©&quot;+year+&quot; Baidu &quot;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>
<p>一个简单的请求,以及下载器就做好啦</p>
<p>附带源码</p>
<p>wget http://8.131.62.10:9081/yuan.tar.gz</p>
1 个赞

宝,早点睡~~~

c++ 666

有效