plugin/quarksoo/html结构分析.md
https://quarksoo.cc/search.php?q={关键词}GETtext/htmlGET https://quarksoo.cc/search.php?q=华山论剑
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>搜索完整剧名</title>
</head>
<body>
<h1>搜索完整剧名</h1>
<form method="get" action="">
<input type="text" name="q" value="华山论剑">
<button type="submit">搜索</button>
</form>
<h2>搜索结果:4 条</h2>
<table>
<tr>
<th>剧名</th>
<th>网盘链接</th>
</tr>
<tr>
<td>华山论剑之九阴真经</td>
<td>
<a href="https://pan.qoark.cn/s/hslj" target="_blank">
夸克网盘
</a>
</td>
</tr>
<tr>
<td>华山论剑之东邪西毒</td>
<td>
<a href="https://pan.qoark.cn/s/dxxd" target="_blank">
夸克网盘
</a>
</td>
</tr>
<!-- 更多结果... -->
</table>
</body>
</html>
<table> 标签<tr><th>剧名</th><th>网盘链接</th></tr>(第一行,可忽略)<tr><td>剧名</td><td><a href="链接">夸克网盘</a></td></tr>| 数据项 | HTML 位置 | 提取方法 |
|---|---|---|
| 剧名 | <tr> 内第一个 <td> | 提取文本内容 |
| 网盘链接 | <tr> 内第二个 <td> 中的 <a href="..."> | 提取 href 属性值 |
| 网盘类型 | 域名特征 | 示例链接 | 说明 |
|---|---|---|---|
| 夸克网盘 | pan.qoark.cn | https://pan.qoark.cn/s/hslj | 主要网盘类型 |
注意:
pan.qoark.cn(注意是 qoark,不是 quark)quark 类型pan.quark.cn 和 pan.qoark.cn| HTML 字段 | 目标字段 | 说明 |
|---|---|---|
第一个 <td> 文本 | Title | 剧名 |
<a href="..."> 的 href | Links[].URL | 网盘链接 |
"" | Links[].Password | 无密码(默认为空) |
"quark" | Links[].Type | 网盘类型(夸克网盘) |
"" | Channel | 插件搜索结果Channel为空 |
[] | Tags | 标签数组(可选) |
| 当前时间 | Datetime | 发布时间(页面中无时间信息,使用当前时间) |
quarksoo-{行号} | UniqueID | 唯一ID |
使用正则表达式匹配表格行:
// 匹配表格行的正则表达式
pattern := `<tr>\s*<td>([^<]+)</td>\s*<td>\s*<a[^>]*href\s*=\s*["']([^"']+)["'][^>]*>`
// 提取所有匹配
re := regexp.MustCompile(pattern)
matches := re.FindAllStringSubmatch(htmlContent, -1)
for _, match := range matches {
title := strings.TrimSpace(match[1]) // 剧名
linkURL := strings.TrimSpace(match[2]) // 网盘链接
}
// 按 <tr> 分割
rows := strings.Split(htmlContent, "<tr>")
for _, row := range rows {
// 跳过表头
if strings.Contains(row, "<th>") {
continue
}
// 提取第一个 <td> 内容(剧名)
// 提取 <a href="..."> 中的链接
}
pan.qoark.cn 或 pan.quark.cnquark 类型searchURL := fmt.Sprintf("https://quarksoo.cc/search.php?q=%s", url.QueryEscape(keyword))
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("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("Referer", "https://quarksoo.cc/")
result := model.SearchResult{
UniqueID: fmt.Sprintf("quarksoo-%d", index),
Title: title,
Links: []model.Link{
{
Type: "quark",
URL: linkURL,
Password: "", // 无密码
},
},
Channel: "", // 插件搜索结果Channel为空
Datetime: time.Now(), // 页面无时间信息,使用当前时间
}
// 从HTML中解析搜索结果
func parseSearchResults(htmlContent string, keyword string) []model.SearchResult {
var results []model.SearchResult
// 提前过滤:检查标题是否包含关键词
lowerKeyword := strings.ToLower(keyword)
keywords := strings.Fields(lowerKeyword)
// 使用正则表达式提取表格行
pattern := `<tr>\s*<td>([^<]+)</td>\s*<td>\s*<a[^>]*href\s*=\s*["']([^"']+)["'][^>]*>`
re := regexp.MustCompile(pattern)
matches := re.FindAllStringSubmatch(htmlContent, -1)
for i, match := range matches {
if len(match) < 3 {
continue
}
title := strings.TrimSpace(match[1])
linkURL := strings.TrimSpace(match[2])
// 验证链接是否为夸克网盘
if !strings.Contains(linkURL, "pan.qoark.cn") && !strings.Contains(linkURL, "pan.quark.cn") {
continue
}
// 检查标题是否包含关键词
lowerTitle := strings.ToLower(title)
titleMatched := true
for _, kw := range keywords {
if !strings.Contains(lowerTitle, kw) {
titleMatched = false
break
}
}
if !titleMatched {
continue
}
// 识别网盘类型
linkType := "quark"
result := model.SearchResult{
UniqueID: fmt.Sprintf("quarksoo-%d", i),
Title: title,
Links: []model.Link{
{
Type: linkType,
URL: linkURL,
Password: "",
},
},
Channel: "",
Datetime: time.Now(),
}
results = append(results, result)
}
return results
}
pan.qoark.cn 或 pan.quark.cnpan.qoark.cn 和 pan.quark.cn 都识别为 quark 类型UniqueID 进行去重UniqueID 格式: quarksoo-{行号}| 特性 | quarksoo | 其他插件 | 说明 |
|---|---|---|---|
| 数据源 | HTML 页面 | JSON API | 需要解析 HTML |
| 链接格式 | HTML 表格 | JSON 对象 | 需要从 HTML 中提取 |
| 解析方法 | 正则表达式 | JSON解析 | HTML 解析更复杂 |
| 时间信息 | 无 | 有 | 使用当前时间 |
NewBaseAsyncPlugin("quarksoo", 3)pan.qoark.cn 或 pan.quark.cn)curl "https://quarksoo.cc/search.php?q=华山论剑" \
-H "Referer: https://quarksoo.cc/" \
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
<tr> 行中提取剧名和网盘链接