-
Notifications
You must be signed in to change notification settings - Fork 0
/
getURLInfoExample.go
39 lines (35 loc) · 1.18 KB
/
getURLInfoExample.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
package main
import (
"bytes"
"fmt"
"github.com/qwer7y/golexaRank"
"io/ioutil"
"strings"
)
func main() {
// Choose the response groups you want
urlInfoResponseGroupList := []string{"RelatedLinks", "Categories", "Rank", "ContactInfo", "RankByCountry", "UsageStats", "Speed", "Language", "OwnedDomains", "LinksInCount", "SiteData", "AdultContent"}
var urlInfoResponseGroups string
length := len(urlInfoResponseGroupList)
for i, val := range urlInfoResponseGroupList {
if i != (length - 1) {
urlInfoResponseGroups += val
urlInfoResponseGroups += "%2C"
} else {
urlInfoResponseGroups += val
}
}
exampleDomain := "www.github.com"
// Reading the credentials required for issuing the requests
accessID := "Add_Your_AccessID_here" // Avoid hardcoding this. Read it from file and add it as an environment variable
secretAccessKey := "Add_Your_SecretAccessKey_here"
// Let's see if the GetUrlInfo function works
response := golexaRank.GetUrlInfo(exampleDomain, urlInfoResponseGroups, accessID, secretAccessKey)
if err != nil {
println("Error reading response.Body")
}
buf := new(bytes.Buffer)
_, err = buf.ReadFrom(response.Body)
newStr := buf.String()
fmt.Println(newStr)
}