add more image urls
This commit is contained in:
parent
0b97f282e2
commit
3a076998f9
5 changed files with 74 additions and 75 deletions
|
@ -6,7 +6,6 @@ import (
|
|||
"log/slog"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type GogFrontStruct struct {
|
||||
|
@ -67,7 +66,7 @@ func (e GogFrontStruct) Load() error {
|
|||
return
|
||||
case tt == html.StartTagToken:
|
||||
t := bodyStore.Token()
|
||||
if t.Data != "a" {
|
||||
if t.Data != "a" { // only <a> tag
|
||||
continue
|
||||
}
|
||||
for _, a := range t.Attr {
|
||||
|
@ -105,39 +104,15 @@ func (e GogFrontStruct) Load() error {
|
|||
}
|
||||
bodyGame := html.NewTokenizer(resGame.Body)
|
||||
|
||||
func() {
|
||||
for {
|
||||
tt := bodyGame.Next()
|
||||
|
||||
switch {
|
||||
case tt == html.ErrorToken:
|
||||
// file end or error
|
||||
return
|
||||
case tt == html.StartTagToken:
|
||||
t := bodyGame.Token()
|
||||
if t.Data != "h1" {
|
||||
continue
|
||||
}
|
||||
for _, a := range t.Attr {
|
||||
if !(a.Key == "class" && a.Val == "productcard-basics__title") {
|
||||
continue
|
||||
}
|
||||
if tt = bodyGame.Next(); tt != html.TextToken {
|
||||
continue
|
||||
}
|
||||
id := fmt.Sprintf("%v%v", e.idPrefix, appID)
|
||||
title := strings.TrimSpace(bodyGame.Token().Data)
|
||||
url := fmt.Sprintf("%v%v", e.baseUrl, appID)
|
||||
|
||||
e.deals[id] = Deal{
|
||||
Id: id,
|
||||
Title: title,
|
||||
Url: url,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
title, image := gogParseMeta(bodyGame)
|
||||
url := fmt.Sprintf("%v%v", e.baseUrl, appID)
|
||||
id := fmt.Sprintf("%v%v", e.idPrefix, appID)
|
||||
e.deals[id] = Deal{
|
||||
Id: id,
|
||||
Title: title,
|
||||
Url: url,
|
||||
Image: image,
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue