fish2018/pansou · error
创建请求失败
Error message
创建请求失败: %v
What it means
Wrapped construction error in PantaAsyncPlugin.doSearch (plugin/panta/panta.go:248): http.NewRequestWithContext failed for the panta search URL (bad URL or expired context) before any request was sent.
Solutions
- 校验 searchURLTemplate 与编码结果
- 对 encodedKeyword 做合法性检查
- 补充构造失败日志
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at plugin/panta/panta.go:248 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/65b4c205b0ed18be.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/panta/panta.go:248
return p.AsyncSearchWithResult(keyword, p.doSearch, p.MainCacheKey, ext)
}
// doSearch 执行具体的搜索逻辑
func (p *PantaAsyncPlugin) doSearch(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {
// 对关键词进行URL编码
encodedKeyword := url.QueryEscape(keyword)
// 构建搜索URL
searchURL := fmt.Sprintf(searchURLTemplate, encodedKeyword)
// 创建一个带有超时的上下文
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(defaultTimeout)*time.Second)
defer cancel()
// 创建请求
req, err := http.NewRequestWithContext(ctx, "GET", searchURL, nil)
if err != nil {
return nil, fmt.Errorf("创建请求失败: %v", err)
}
// 设置User-Agent和Referer
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
req.Header.Set("Referer", "https://www.91panta.cn/index")
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
req.Header.Set("Connection", "keep-alive")
req.Header.Set("Upgrade-Insecure-Requests", "1")
req.Header.Set("Cache-Control", "max-age=0")
// 使用带重试的请求方法发送HTTP请求
resp, err := p.doRequestWithRetry(req, client)
if err != nil {
return nil, fmt.Errorf("请求PanTa搜索页面失败: %v", err)
}
defer resp.Body.Close()
View on GitHub (pinned to beaa561337)