Esempio n. 1
0
func (e extractComic) setImage(a *Article, img *goquery.Selection) bool {
	if img.Length() == 0 {
		return false
	}

	img = img.First()

	src, ok := img.Attr("src")
	if !ok {
		return false
	}

	i := hitImage(src)
	if i == nil {
		return false
	}

	title, _ := img.Attr("title")
	if title == "" {
		title, _ = img.Attr("alt")
	}

	a.Img = i
	a.CleanedText = title
	a.addInlineArticleImageHTML(title)

	return true
}
Esempio n. 2
0
func getText(s *goquery.Selection, includeDecendents bool) string {
	if s.Length() == 0 {
		return ""
	}
	if includeDecendents {
		return strings.TrimSpace(s.Text())
	}
	var buff []string
	for node := s.First().Nodes[0].FirstChild; node != nil; node = node.NextSibling {
		if node.Type == html.TextNode {
			buff = append(buff, node.Data)
		}
	}
	return strings.TrimSpace(strings.Join(buff, ""))
}
Esempio n. 3
0
func isValidGameList(selection *goquery.Selection) bool {
	tdCount := selection.First().Children().Length()
	return tdCount == 6 || tdCount == 4
}
Esempio n. 4
0
func hasImages(rawGames *goquery.Selection) bool {
	return rawGames.First().Children().Length() == 6
}