doukou4066 2015-11-07 01:59
浏览 869

获取net / http:TLS握手超时golang

Need your help with this

package main

import (
    "log"
    "net/http"
)

func main() {
    client := &http.Client{}
    _, err := client.Get("https://www.marathonbet.com/en/")
    if err != nil {
        log.Fatalf("%s
", err)
    }
}

This always return:Get https://www.marathonbet.com/en/: net/http: TLS handshake timeout exit status 1 I`m try: it and use this lib and do it But nothing works for me.. So, please help me.

Update: In Python 2.7 with requests this works:

s = Session()
r = s.get('https://www.marathonbet.com/en/, verify=False)

But i need do it with go(

UPD: Fixed: Just replase https://www.marathonbet.com/en/ to https://87.117.250.213/en/ and adding skip verify. thx all for help.

  • 写回答

1条回答 默认 最新

  • donglaoping9702 2015-11-07 23:54
    关注

    Disable verify

    package main
    
    import (
        "crypto/tls"
        "fmt"
        "io/ioutil"
        "net/http"
        "os"
    )
    
    func main() {
        // Create New http Transport
        transCfg := &http.Transport{
            TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // disable verify
        }
        // Create Http Client
        client := &http.Client{Transport: transCfg}
        // Request
        response, err := client.Get("https://www.marathonbet.com/en/")
        // Check Error
        if err != nil {
            fmt.Println(err)
            os.Exit(1)
        }
        // Close After Read Body
        defer response.Body.Close()
        // Read Body
        data, err := ioutil.ReadAll(response.Body)
        // Check Error
        if err != nil {
            fmt.Println(err)
            os.Exit(1)
        }
        // Print response html : conver byte to string
        fmt.Println(string(data))
    
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题