This repository has been archived by the owner on Sep 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
club.go
58 lines (51 loc) · 1.89 KB
/
club.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
package parser
import (
"net/http"
"github.com/rl404/go-malscraper/model"
"github.com/rl404/go-malscraper/pkg/utils"
)
// GetClubs to get club list.
func (p *Parser) GetClubs(page int) ([]model.ClubSearch, int, error) {
q := map[string]interface{}{"p": page}
doc, code, err := p.getDoc(utils.BuildURLWithQuery(q, malURL, "clubs.php"), "#contentWrapper")
if err != nil {
return nil, code, err
}
return p.search.GetClub(doc), http.StatusOK, nil
}
// GetClub to get club detail information.
func (p *Parser) GetClub(id int) (*model.Club, int, error) {
q := map[string]interface{}{"cid": id}
doc, code, err := p.getDoc(utils.BuildURLWithQuery(q, malURL, "clubs.php"), "#contentWrapper")
if err != nil {
return nil, code, err
}
return p.club.GetDetails(doc), http.StatusOK, nil
}
// GetClubMember to get club member list.
func (p *Parser) GetClubMember(id int, page int) ([]model.ClubMember, int, error) {
q := map[string]interface{}{"id": id, "action": "view", "t": "members", "show": 36 * (page - 1)}
doc, code, err := p.getDoc(utils.BuildURLWithQuery(q, malURL, "clubs.php"), "#content")
if err != nil {
return nil, code, err
}
return p.club.GetMembers(doc), http.StatusOK, nil
}
// GetClubPicture to get club picture list.
func (p *Parser) GetClubPicture(id int) ([]string, int, error) {
q := map[string]interface{}{"id": id, "action": "view", "t": "pictures"}
doc, code, err := p.getDoc(utils.BuildURLWithQuery(q, malURL, "clubs.php"), "#content")
if err != nil {
return nil, code, err
}
return p.club.GetPictures(doc), http.StatusOK, nil
}
// GetClubRelated to get club related list.
func (p *Parser) GetClubRelated(id int) (*model.ClubRelated, int, error) {
q := map[string]interface{}{"cid": id}
doc, code, err := p.getDoc(utils.BuildURLWithQuery(q, malURL, "clubs.php"), "#contentWrapper")
if err != nil {
return nil, code, err
}
return p.club.GetRelated(doc), http.StatusOK, nil
}