/
fuman.go
218 lines (161 loc) · 5.64 KB
/
fuman.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package reader
import (
"errors"
"net/url"
"regexp"
"strings"
"github.com/PuerkitoBio/goquery"
"github.com/lunny/html2md"
)
//FumanReader 腐漫漫画 (盗版漫画网站)
type FumanReader struct {
}
// GetCategories 获取所有分类
func (r FumanReader) GetCategories(urlStr string) (list Catalog, err error) {
// urlStr := `http://m.booktxt.com/`
list.Title = `分类-腐漫漫画`
list.SourceURL = urlStr
list.Hash = GetCatalogHash(list)
list.Cards = []Card{
Card{`全部`, `/pages/list?action=list&drive=fuman&url=` + EncodeURL(`https://www.fuman.cc/booklist?tag=%E5%85%A8%E9%83%A8&area=-1&end=-1`), "", `link`, ``, nil, ``, ``},
Card{`伦理`, `/pages/list?action=list&drive=fuman&url=` + EncodeURL(`https://www.fuman.cc/booklist?tag=%E4%BC%A6%E7%90%86&area=-1&end=-1`), "", `link`, ``, nil, ``, ``},
Card{`恋爱`, `/pages/list?action=list&drive=fuman&url=` + EncodeURL(`https://www.fuman.cc/booklist?tag=%E6%81%8B%E7%88%B1&area=-1&end=-1`), "", `link`, ``, nil, ``, ``},
Card{`情感`, `/pages/list?action=list&drive=fuman&url=` + EncodeURL(`https://www.fuman.cc/booklist?tag=%E6%83%85%E6%84%9F&area=-1&end=-1`), "", `link`, ``, nil, ``, ``},
Card{`OL`, `/pages/list?action=list&drive=fuman&url=` + EncodeURL(`https://www.fuman.cc/booklist?tag=OL&area=-1&end=-1`), "", `link`, ``, nil, ``, ``},
Card{`暧昧`, `/pages/list?action=list&drive=fuman&url=` + EncodeURL(`https://www.fuman.cc/booklist?tag=%E6%9A%A7%E6%98%A7&area=-1&end=-1`), "", `link`, ``, nil, ``, ``},
Card{`韩国`, `/pages/list?action=list&drive=fuman&url=` + EncodeURL(`https://www.fuman.cc/booklist?tag=%E5%85%A8%E9%83%A8&area=1&end=-1`), "", `link`, ``, nil, ``, ``},
}
return list, nil
}
// GetList 获取书籍列表列表
func (r FumanReader) GetList(urlStr string) (list Catalog, err error) {
err = CheckStrIsLink(urlStr)
if err != nil {
return
}
html, err := GetHTML(urlStr, ``)
if err != nil {
return
}
g, e := goquery.NewDocumentFromReader(strings.NewReader(html))
if e != nil {
return list, e
}
list.Title = FindString(`免费韩漫列表-(?P<title>(.)+)`, g.Find("title").Text(), "title")
if list.Title == `` {
list.Title = g.Find("title").Text()
}
link, _ := url.Parse(urlStr)
var links = GetLinks(g, link)
var needLinks []Link
var state bool
reg := regexp.MustCompile(`【([^<]+)】`)
for _, l := range links {
l.URL, state = JaccardMateGetURL(l.URL, `https://www.fuman.cc/book/400`, `https://www.fuman.cc/book/25`, ``)
if state {
//完结
l.Title = reg.ReplaceAllString(l.Title, "")
// l.Title = FindString(`(?P<title>(.)+)`, l.Title, "title")
needLinks = append(needLinks, l)
}
}
list.Cards = LinksToCards(Cleaning(needLinks), `/pages/catalog`, `fuman`)
list.SourceURL = urlStr
list.Next = GetNextLink(links)
if list.Next.URL != `` {
list.Next.URL = EncodeURL(list.Next.URL)
}
list.Hash = GetCatalogHash(list)
return list, nil
}
// Search 搜索资源
func (r FumanReader) Search(keyword string) (list Catalog, err error) {
return
}
// GetCatalog 获取章节列表
func (r FumanReader) GetCatalog(urlStr string) (list Catalog, err error) {
err = CheckStrIsLink(urlStr)
if err != nil {
return
}
html, err := GetHTML(urlStr, ``)
if err != nil {
return
}
g, e := goquery.NewDocumentFromReader(strings.NewReader(html))
if e != nil {
return list, e
}
list.Title = FindString(`】(?P<title>(.)+)韩漫大全无删减版在线观看-腐漫漫画`, g.Find("title").Text(), "title")
if list.Title == `` {
list.Title = g.Find("title").Text()
}
// reg := regexp.MustCompile(`【([^<]+)】`)
// list.Title = reg.ReplaceAllString(list.Title, "")
link, _ := url.Parse(urlStr)
// html2, _ := g.Find(`#detail-list-select`).Eq(1).Html()
g2, e := goquery.NewDocumentFromReader(strings.NewReader(html))
var links = GetLinks(g2, link)
var needLinks []Link
var state bool
for _, l := range links {
l.URL, state = JaccardMateGetURL(l.URL, `https://www.fuman.cc/chapter/1011`, `https://www.fuman.cc/chapter/1018`, ``)
if state {
needLinks = append(needLinks, l)
}
}
list.Cards = LinksToCards(Cleaning(needLinks), `/pages/article`, `fuman`)
list.SourceURL = urlStr
var links2 = GetLinks(g, link)
list.Next = GetNextLink(links2)
if list.Next.URL != `` {
list.Next.URL = EncodeURL(list.Next.URL)
}
list.Hash = GetCatalogHash(list)
return list, nil
}
// GetInfo 获取详细内容
func (r FumanReader) GetInfo(urlStr string) (ret Content, err error) {
err = CheckStrIsLink(urlStr)
if err != nil {
return
}
html, err := GetHTML(urlStr, ``)
if err != nil {
return ret, err
}
// log.Println(html)
html2, err := FindContentHTML(html, `.comicpage`)
// g2, e2 := goquery.NewDocumentFromReader(strings.NewReader(html2))
// html2article
article, err := GetActicleForHTML(html2)
if err != nil {
return ret, err
}
article.Readable(urlStr)
if CheckStrIsLink(urlStr) != nil {
return ret, errors.New(`url error`)
}
ret.Title = FindString(`】(?P<title>(.)+)免费阅读-腐漫漫画`, article.Title, "title")
if ret.Title == `` {
ret.Title = article.Title
}
// reg := regexp.MustCompile(`【([^<]+)】`)
// ret.Title = reg.ReplaceAllString(ret.Title, "")
// ret.Content = article.ReadContent
ret.Content = ImagesBuildHTML(article.Images)
ret.Content = html2md.Convert(ret.Content)
// ret.PubAt = string(article.Publishtime)
ret.SourceURL = urlStr
links, _ := GetLinkByHTML(urlStr, html)
// log.Println(`article.Images`, links, ImagesBuildHTML(article.Images))
ret.Previous = GetPreviousLink(links)
if ret.Previous.URL != `` {
ret.Previous.URL = EncodeURL(ret.Previous.URL)
}
ret.Next = GetNextLink(links)
if ret.Next.URL != `` {
ret.Next.URL = EncodeURL(ret.Next.URL)
}
return ret, nil
}