-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
76 lines (70 loc) · 1.66 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"bufio"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
type Response struct {
Data []struct {
Da string `json:"DA"`
Pa string `json:"PA"`
Moz string `json:"Moz_Rank"`
BackLink string `json:"Back_Links"`
} `json:"data"`
}
func main() {
var list string
fmt.Println("Credit @zeruproject")
fmt.Print("Your list: ")
fmt.Scanln(&list)
CheckDapa(list)
}
func Api(url string) {
var data Response
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Transport: transport,
Timeout: 120 * time.Second,
}
request, err := http.NewRequest("GET", "https://tools.helixs.id/API/dapa?url="+url, nil)
if err != nil {
fmt.Print(err.Error())
}
response, err := client.Do(request)
if err != nil {
fmt.Print(err.Error())
}
body, _ := io.ReadAll(response.Body)
defer response.Body.Close()
if err := json.Unmarshal(body, &data); err != nil {
fmt.Print(err.Error())
}
result := fmt.Sprintf("Url : %s [DA : %v] [PA : %v] [Moz : %v] [Backlink : %v]", url, data.Data[0].Da, data.Data[0].Pa, data.Data[0].Moz, data.Data[0].BackLink)
fmt.Println(result)
file, err := os.OpenFile("result.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Print(err.Error())
}
_, err = fmt.Fprintf(file, result+"\n")
if err != nil {
fmt.Print(err.Error())
}
}
func CheckDapa(list string) {
file, err := os.Open(list)
if err != nil {
fmt.Print(err.Error())
}
scanner := bufio.NewScanner(file)
for scanner.Scan() {
weblist := scanner.Text()
Api(weblist)
}
}