-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimpl_bingmh.go
59 lines (38 loc) · 999 Bytes
/
impl_bingmh.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"strings"
"github.com/PuerkitoBio/goquery"
)
// https://bingmh.com/ 网站,实现了 MyWeb 接口
type Bingmh struct {
}
func (x Bingmh) ComicName(doc *goquery.Document) string {
return doc.Find("h1.comic-name").First().Text()
}
func (x Bingmh) PageUrl(doc *goquery.Document) []OnePage {
var ret []OnePage
doc.Find("li.chapter-item a").Each(func(i int, s *goquery.Selection) {
href, _ := s.Attr("href")
itemUrl := "https://bingmh.com" + href
ret = append(ret, OnePage{
Url: itemUrl,
Name: s.Text(),
})
})
// 逆序, 代码来自 chatgpt
// for i := len(ret)/2 - 1; i >= 0; i-- {
// opp := len(ret) - 1 - i
// ret[i], ret[opp] = ret[opp], ret[i]
// }
return ret
}
func (x Bingmh) ImgList(doc *goquery.Document) []string {
var ret []string
doc.Find("li.comic-page img").Each(func(i int, s *goquery.Selection) {
src, _ := s.Attr("src")
if strings.HasPrefix(src, "http") {
ret = append(ret, src)
}
})
return ret
}