-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile1.go
48 lines (44 loc) · 1.4 KB
/
file1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package headless
import (
"context"
"fmt"
"github.com/chromedp/chromedp"
"time"
)
type Technology struct {
ID int `json:"id"`
Tech string `json:"tech"`
}
func RunWithTimeOut(ctx *context.Context, timeout time.Duration, tasks chromedp.Tasks) chromedp.ActionFunc {
return func(ctx context.Context) error {
timeoutContext, cancel := context.WithTimeout(ctx, timeout*time.Second)
defer cancel()
return tasks.Do(timeoutContext)
}
}
func ResponseError(err error, redir string, urlORredir string, url string) bool {
if err != nil {
e := err.Error()
switch e {
case "page load error net::ERR_CERT_COMMON_NAME_INVALID",
"page load error net::ERR_NAME_NOT_RESOLVED",
"page load error net::ERR_CONNECTION_REFUSED",
"page load error net::ERR_CONNECTION_CLOSED",
"Could not find node with given id (-32000)",
"page load error net::ERR_CERT_DATE_INVALID",
"page load error net::ERR_CONNECTION_RESET",
"page load error net::ERR_TIMED_OUT",
"page load error net::ERR_TOO_MANY_REDIRECTS",
"page load error net::ERR_CERT_AUTHORITY_INVALID":
fmt.Println(err, "|", redir, "->", urlORredir, url)
case "page load error net::ERR_NETWORK_CHANGED":
fmt.Println("NETWORK CHANGED/CONNECTION DROP", err, redir, "->", urlORredir, url)
default:
fmt.Println("NEW ERROR TYPE", err, "|", urlORredir, url)
}
return false
} else {
fmt.Println("OK#1--> ", urlORredir, url)
return true
}
}