MCPcopy Create free account
hub / github.com/FloatTech/AnimeAPI / Cat

Function Cat

pixiv/cat.go:34–67  ·  view source on GitHub ↗

Cat 调用 pixiv.cat 的 generate API

(id int64)

Source from the content-addressed store, hash-verified

32
33// Cat 调用 pixiv.cat 的 generate API
34func Cat(id int64) (*Generate, error) {
35 data, err := web.RequestDataWithHeaders(&http.Client{
36 Transport: &http.Transport{
37 DialTLS: func(network, addr string) (net.Conn, error) {
38 return tls.Dial("tcp", "66.42.35.2:443", &tls.Config{
39 ServerName: "api.pixiv.cat",
40 MaxVersion: tls.VersionTLS12,
41 })
42 },
43 }},
44 "https://api.pixiv.cat/v1/generate",
45 "POST",
46 func(r *http.Request) error {
47 r.Header.Set("authority", "api.pixiv.cat")
48 r.Header.Set("accept", "*/*")
49 r.Header.Set("accept-language", "zh,zh-CN;q=0.9,zh-HK;q=0.8,zh-TW;q=0.7,ja;q=0.6,en;q=0.5,en-GB;q=0.4,en-US;q=0.3")
50 r.Header.Set("content-type", "application/x-www-form-urlencoded; charset=UTF-8")
51 r.Header.Set("origin", "https://pixiv.cat")
52 r.Header.Set("referer", "https://pixiv.cat/")
53 r.Header.Set("user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.76")
54 return nil
55 },
56 strings.NewReader("p="+url.QueryEscape("https://www.pixiv.net/member_illust.php?illust_id="+strconv.FormatInt(id, 10))),
57 )
58 if err != nil {
59 return nil, err
60 }
61 g := &Generate{}
62 err = json.Unmarshal(data, g)
63 if err != nil {
64 return nil, err
65 }
66 return g, nil
67}

Callers 2

WorksFunction · 0.85
TestCatFunction · 0.85

Calls 1

SetMethod · 0.80

Tested by 1

TestCatFunction · 0.68