A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© laical123 中级黑马   /  2021-11-24 16:14  /  1636 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

日前,国家统计局发布《中国统计年鉴2021》(以下称《统计年鉴》)披露了人口等多方面的数据。其中男人比例的公布引起了大家的注意。全国乡村人口性别比为107.91,反映出我国男女人口性别比失衡现象在乡村地区尤为明显,近期热点“暖农村大龄男青年被窝工程”也引起了大家的激烈讨论。
从地区分析,我国 31 个省份乡村人口性别比均大于 100,包括:北京 120.21、山西 110.07、内蒙古 112.26、上海 130.93、浙江 110.82等。另外有 11 个省份城市人口性别比小于 100(女 =100,即女性多于男性),包括:河北 99.02、山西 99.70、内蒙古 99.63、辽宁 97.53、吉林 95.56等,需要更多具体的地区信息,运行下面的程序,可以及时获取相关咨询:
[Golang] 纯文本查看 复制代码
        package main

        import (
            "net/url"
            "net/http"
            "bytes"
            "fmt"
            "io/ioutil"
        )

        // 代理服务器(产品官网 www.16yun.cn)
        const ProxyServer = "t.16yun.cn:31111"

        type ProxyAuth struct {
            Username string
            Password string
        }

        func (p ProxyAuth) ProxyClient() http.Client {

            var proxyURL *url.URL
            if p.Username != ""&& p.Password!="" {
                proxyURL, _ = url.Parse("http://" + p.Username + ":" + p.Password + "@" + ProxyServer)
            }else{
                proxyURL, _ = url.Parse("http://" + ProxyServer)
            }
            return http.Client{Transport: &http.Transport{Proxy:http.ProxyURL(proxyURL)}}
        }

        func main()  {

            targetURI := "https://www.thepaper.cn/newsDetail_forward_15529051"

            // 初始化 proxy http client
            client := ProxyAuth{"username",  "password"}.ProxyClient()

            request, _ := http.NewRequest("GET", targetURI, bytes.NewBuffer([] byte(``)))

            // 设置Proxy-Tunnel
            // rand.Seed(time.Now().UnixNano())
            // tunnel := rand.Intn(10000)
            // request.Header.Set("Proxy-Tunnel", strconv.Itoa(tunnel) )

            response, err := client.Do(request)

            if err != nil {
                panic("failed to connect: " + err.Error())
            } else {
                bodyByte, err := ioutil.ReadAll(response.Body)
                if err != nil {
                    fmt.Println("读取 Body 时出错", err)
                    return
                }
                response.Body.Close()

                body := string(bodyByte)

                fmt.Println("Response Status:", response.Status)
                fmt.Println("Response Header:", response.Header)
                fmt.Println("Response Body:\n", body)
            }
        }

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马