12345678910111213141516171819202122232425262728293031323334 |
- package cafe24
- import (
- "kkscrap-go/controllers/scraper/common"
- util "kkscrap-go/controllers/scraper/util"
- "kkscrap-go/model"
- "strings"
- "github.com/PuerkitoBio/goquery"
- )
- func Parse(body string, item *model.ItemInfo) {
- item.Language = common.GetLanguage(body)
- doc, err := goquery.NewDocumentFromReader(strings.NewReader(body))
- util.CheckError(err)
- //s := doc.Find("meta[property=\"og:url\"]")
- doc.Find("link ~ meta").Each(func(i int, s *goquery.Selection) {
- v, _ := s.Attr("property")
- if v == "og:description" {
- item.ShortDesc = s.AttrOr("content", "")
- } else if v == "og:title" {
- item.ItemName = s.AttrOr("content", "")
- } else if v == "og:image" {
- item.Images = append(item.Images, s.AttrOr("content", ""))
- } else if v == "product:price:amount" {
- item.SalesPrice = util.GetFloat32(s.AttrOr("content", ""))
- } else if v == "product:price:currency" {
- item.Currency = s.AttrOr("content", "")
- }
- })
- item.Emails = common.GetEmails(body)
- return
- }
|