package main
import (
"encoding/hex"
"fmt"
"strings"
)
func main() {
url := `http://www.seek4info.com/search/result/?q=web%20hosting&view=0`
pq := strings.Split(url, "?")[1]
fmt.Printf("pq: %s\n", pq)
params := strings.Split(pq, "&")
fmt.Printf("params: %s\n", params)
for _, param := range params {
percent := strings.Split(param, "%")
fmt.Printf("percent: %s\n", percent)
var s string
if len(percent) > 1 {
for i, part := range percent {
fmt.Printf("part: %s\n", part)
if i == 0 {
s += part
} else {
bl, _ := hex.DecodeString(part[:2])
tmp := string(bl)
s += tmp
s += part[2:]
}
}
} else {
s = param
}
fmt.Printf("(result)s: %s\n", s)
}
}
/*
run:
pq: q=web%20hosting&view=0
params: [q=web%20hosting view=0]
percent: [q=web 20hosting]
part: q=web
part: 20hosting
(result)s: q=web hosting
percent: [view=0]
(result)s: view=0
*/