wangluozhe / requests

用于快速请求HTTP或HTTPS,并支持修改ja3、ja4指纹
GNU General Public License v3.0
430 stars 100 forks source link

链接中包含#解析Params出错 #65

Closed nicaicaii closed 8 months ago

nicaicaii commented 8 months ago
       u :="https://www.yangshipin.cn/#/video/home?vid=b000015axds&cid=518iuubyz1txkbw"
    ud, err := url.Parse(u)
    if err != nil {
        log.Error(err)
        return
    }
    cid := ud.Params.Get("cid")

是不是应该先按?切分

url.go
func Parse(rawURL string) (*URL, error) {
    url, err := parse(rawURL, false)
    if err != nil {
        return nil, &Error{"parse", rawURL, err}
    }
    return url, nil
}

func parse(rawURL string, viaRequest bool) (*URL, error) {
......................................................................................................
    url.Scheme = strings.ToLower(url.Scheme)

    rest, tempQuery, _ := strings.Cut(rest, "?")
    url.RawQuery, frag, _ = strings.Cut(tempQuery, "#")
    if tempQuery=="" {
        url.ForceQuery = true
        rest = rest[:len(rest)]
    }
    if frag != "" {
        err := url.setFragment(frag)
        if err != nil {
            return nil, &Error{"parse", rawURL, err}
        }
    }

    if !strings.HasPrefix(rest, "/") {
....................................................................