猫史档案馆


高匿代理IP的作用

用户:LaicalLaical查看:0 回复:0 评论:0 创建时间:2021-02-02T17:22:33


互联网的大数据喵的来临,网络爬虫对http代理的使用量越来越大,但是对于网络爬虫来说面对的问题就是如何选择http代理时更加谨慎。作为一个隧道转发的高匿爬虫代理加强版的HTTP代理,高匿爬虫http代理的出现无疑是一个巨大的进步。网络爬虫在使用高匿http代理时不用再担心个人的隐私安全问题,可以在一个比较安全的环境中使用http代理,这将会提高使用者对高匿http代理的运用量。

作为高匿HTTP代理,隧道转发的爬虫代理加强版,使得用户越来越多,网络爬虫加入使用http代理的队伍中,这对于http代理行业的发展,是一个巨大的推动力。

高匿ip是各大IP类型中。匿名程度可以说是目前最好的了。如果你急需使用如此高匿名的代理,就可以使用隧道转发的爬虫代理加强版

一般都是做爬虫程序,数据采集网页采集的用http爬虫的比较多,代理IP的安全性和稳定性是很多做爬虫工作者的首选,代理IP的安全性和稳定性是很多朋友的首选,但是网上的很多代理IP都是从网上直接扫描的,安全性和稳定性都没有保证,隧道转发爬虫代理加强版,可用率比较高,全高匿名。

        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://httpbin.org/ip"


            // 初始化 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)
            }
        }
 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://httpbin.org/ip" 

 // 初始化 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)  }  }


回复

上一页1 页 / 共 0下一页