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 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错