gocolly / colly

Elegant Scraper and Crawler Framework for Golang
https://go-colly.org/
Apache License 2.0
23.2k stars 1.76k forks source link

How to ignore expired SSL certificates in Colly? #88

Closed killernova closed 6 years ago

killernova commented 6 years ago

Since I need to visit an unsafe website over https, the Post / Get method will return an error: x509: certificate has expired or is not yet valid. I know I can use InsecureSkipVerify: true when start a request using net / http package, but what should I do if I want to skip SSL certificate check in Colly?

pukuldua commented 6 years ago

Hi @killernova , how you solve this error: x509: certificate has expired or is not yet valid. problem?

asciimoo commented 6 years ago

@pukuldua you can do it by defining a custom http transport for the collector:


import (
    "net/http"
    "crypto/tls"
    "github.com/gocolly/colly"
)

// ...

c := colly.NewCollector()
c.WithTransport(&http.Transport{
    TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
})