package main import ( "fmt" "io/ioutil" "net/http" "regexp" "strings" ) func main() { // 仅对非会员视频链接有效 url := "https://v.qq.com/x/page/b0945ug7vzo.html" // 先确定 .html 的最早出现的位置,以排除之后 callback 的链接中可能携带的 .html b := strings.Index(url, ".html") // 从确定的 .html 向前找最后一个 / 出现的位置 a := strings.LastIndex(url[:b], "/") // 获取视频 id vid := url[a+1 : b] // 获取视频 json 信息 url = "https://vv.video.qq.com/getinfo?vids=" + vid + "&platform=101001&charge=0&otype=json" resp, err := http.Get(url) if err != nil { fmt.Println(err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt