-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.go
69 lines (57 loc) · 1.33 KB
/
common.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
package handset
import (
"fmt"
"net/url"
"strconv"
"time"
)
//模拟php iconv 编码转换
func iconv(fromEncoding string, toEncoding string, str string) (content string) {
if fromEncoding == "GBK" && toEncoding == "UTF-8" {
content = str + "OK"
} else {
content = str + "NOT OK"
}
return
}
//生成showji.com URl
func createShowjiUrl(mobileNo int) *url.URL {
cc := new(url.URL)
cc.Scheme = "http"
cc.Host = "opendata.baidu.com/api.php"
q := cc.Query()
q.Set("query", strconv.Itoa(mobileNo)+".")
q.Set("co", "")
q.Set("resource_id", "6004")
q.Set("t", string([]byte(fmt.Sprintf("%v", time.Now().UnixNano()))[0:13]))
q.Set("ie", "utf8")
q.Set("oe", "gbk")
q.Set("cb", "")
q.Set("format", "json")
q.Set("tn", "baidu")
cc.RawQuery = q.Encode()
return cc
}
//生成ip138.com URL
func createIp138Url(mobileNo int) *url.URL {
cc := new(url.URL)
cc.Scheme = "http"
cc.Host = "www.ip138.com:8080/search.asp"
q := cc.Query()
q.Set("mobile", strconv.Itoa(mobileNo))
q.Set("action", "mobile")
cc.RawQuery = q.Encode()
return cc
}
//生成imobile.com URL
func createImobileUrl(mobileNo int) *url.URL {
cc := new(url.URL)
cc.Scheme = "http"
cc.Host = "search.imobile.com.cn/index.php"
q := cc.Query()
q.Set("keyword", strconv.Itoa(mobileNo))
q.Set("a", "search")
q.Set("scope", "all")
cc.RawQuery = q.Encode()
return cc
}