コード例 #1
0
ファイル: extract_comic.go プロジェクト: oudommeas/swan
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
}
コード例 #2
0
ファイル: goquery_helper.go プロジェクト: speedland/service
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, ""))
}
コード例 #3
0
ファイル: gameParser.go プロジェクト: sejoharp/kickerstats
func isValidGameList(selection *goquery.Selection) bool {
	tdCount := selection.First().Children().Length()
	return tdCount == 6 || tdCount == 4
}
コード例 #4
0
ファイル: gameParser.go プロジェクト: sejoharp/kickerstats
func hasImages(rawGames *goquery.Selection) bool {
	return rawGames.First().Children().Length() == 6
}