-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (36 loc) · 880 Bytes
/
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
package main
import (
"fmt"
"net/url"
"reflect"
)
func main() {
address := "https://www.toko-kita.com/dataproduk?databrand_id=181808782&variations%5B%5D=302008457&variations%5B%5D=302008463"
u, err := url.Parse(address)
if err != nil {
panic(err)
}
fmt.Println("query: ", u.RawQuery)
q, err := url.ParseQuery(u.RawQuery)
if err != nil {
panic(err)
}
brandID := q.Get("databrand_id")
if brandID == "" {
fmt.Println("Kosong")
} else {
fmt.Println("brandID: ", brandID)
}
variations := q.Get("&variations[]")
if variations == "" {
fmt.Println("Kosong variations")
} else {
fmt.Println("variations", variations)
}
getQuery := u.Query()
dataApa := getQuery["sort"]
fmt.Println("dataApa: ", reflect.TypeOf(dataApa), ": ", dataApa)
fmt.Println("getQuery: ", getQuery)
fmt.Println(reflect.TypeOf(getQuery))
fmt.Println(getQuery.Get("sort"))
}