huashijie_go/pkg/huashijie_api.go
yzqzss 63ebe20afb
All checks were successful
Gitea Go Release Actions / Release Go Binary (amd64, linux) (push) Successful in 41s
Gitea Go Release Actions / Release Go Binary (amd64, darwin) (push) Successful in 58s
Gitea Go Release Actions / Release Go Binary (amd64, windows) (push) Successful in 35s
Gitea Go Release Actions / Release Go Binary (arm64, darwin) (push) Successful in 26s
Gitea Go Release Actions / Release Go Binary (arm, linux) (push) Successful in 1m6s
Gitea Go Release Actions / Release Go Binary (arm64, linux) (push) Successful in 32s
Gitea Go Release Actions / Release Go Binary (mips, linux) (push) Successful in 29s
Gitea Go Release Actions / Release Go Binary (loong64, linux) (push) Successful in 1m9s
Gitea Go Release Actions / Release Go Binary (riscv64, linux) (push) Successful in 28s
switch back to main channel
switch to https endpoint
2024-06-28 04:46:37 +08:00

64 lines
1.2 KiB
Go

package huashijie_api
import (
"fmt"
"io"
"math/rand"
"net/http"
)
var XIAOMI_MODELS = []string{
"2107119DC",
"23116PN5BC",
"23124RN87C",
"24031PN0DC",
"24072PX77C",
"24074RPD2C",
"M1804E4A",
"M1810E5GG",
"M2001J1C",
"M2002J9E",
"MDE5",
}
func GetWorkDetailResponse(client http.Client, work_id string) ([]byte, int) {
req, err := http.NewRequest("GET", "https://app.huashijie.art/api/work/detailV2", nil)
if err != nil {
panic(err)
}
q := req.URL.Query()
q.Add("visitorId", "-1")
q.Add("workId", work_id)
q.Add("cur_user_id", "-1")
q.Add("platform", "android")
os_version := rand.Intn(34-28) + 28
q.Add("os_version", fmt.Sprintf("%d", os_version))
q.Add("version_code", "241")
q.Add("device_brand", "xiaomi")
device_model := XIAOMI_MODELS[rand.Intn(len(XIAOMI_MODELS))]
q.Add("device_model", device_model)
q.Add("token", "")
q.Add("channel", "main")
headers := map[string][]string{
"Referer": {"https://app.huashijie.art/"},
"User-Agent": {"okhttp/3.12.0"},
}
for k, v := range headers {
req.Header[k] = v
}
req.URL.RawQuery = q.Encode()
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
return body, resp.StatusCode
}