当前位置: 首页>>代码示例>>Golang>>正文


Golang Selection.Html方法代码示例

本文整理汇总了Golang中github.com/PuerkitoBio/goquery.Selection.Html方法的典型用法代码示例。如果您正苦于以下问题:Golang Selection.Html方法的具体用法?Golang Selection.Html怎么用?Golang Selection.Html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/PuerkitoBio/goquery.Selection的用法示例。


在下文中一共展示了Selection.Html方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: commonPrase

func (b baiduNews) commonPrase(ctx *Context) (infoStr string) {
	body := ctx.GetDom().Find("body")

	var info *goquery.Selection

	if h1s := body.Find("h1"); len(h1s.Nodes) != 0 {
		for i := 0; i < len(h1s.Nodes); i++ {
			info = b.findP(h1s.Eq(i))
		}
	} else if h2s := body.Find("h2"); len(h2s.Nodes) != 0 {
		for i := 0; i < len(h2s.Nodes); i++ {
			info = b.findP(h2s.Eq(i))
		}
	} else if h3s := body.Find("h3"); len(h3s.Nodes) != 0 {
		for i := 0; i < len(h3s.Nodes); i++ {
			info = b.findP(h3s.Eq(i))
		}
	} else {
		info = body.Find("body")
	}
	infoStr, _ = info.Html()

	// 清洗HTML
	infoStr = CleanHtml(infoStr, 5)
	return
}
开发者ID:liangmiaoling,项目名称:spider_lib,代码行数:26,代码来源:baidunews.go

示例2: commonPrase

func (b baiduNews) commonPrase(resp *context.Response) (infoStr string) {
	body := resp.GetDom().Find("body")

	var info *goquery.Selection

	if h1s := body.Find("h1"); len(h1s.Nodes) != 0 {
		for i := 0; i < len(h1s.Nodes); i++ {
			info = b.findP(h1s.Eq(i))
		}
	} else if h2s := body.Find("h2"); len(h2s.Nodes) != 0 {
		for i := 0; i < len(h2s.Nodes); i++ {
			info = b.findP(h2s.Eq(i))
		}
	} else if h3s := body.Find("h3"); len(h3s.Nodes) != 0 {
		for i := 0; i < len(h3s.Nodes); i++ {
			info = b.findP(h3s.Eq(i))
		}
	} else {
		info = body.Find("body")
	}
	// 去除标签
	// info.RemoveFiltered("script")
	// info.RemoveFiltered("style")
	infoStr, _ = info.Html()

	// 清洗HTML
	infoStr = CleanHtml(infoStr, 5)
	return
}
开发者ID:timesking,项目名称:spider_lib,代码行数:29,代码来源:baidunews.go

示例3: findSigInTweet

func (rc *TwitterChecker) findSigInTweet(h SigHint, s *goquery.Selection) ProofError {

	inside := s.Text()
	html, err := s.Html()

	checkText := h.checkText

	if err != nil {
		return NewProofError(keybase1.ProofStatus_CONTENT_FAILURE, "No HTML tweet found: %s", err)
	}

	G.Log.Debug("+ Checking tweet '%s' for signature '%s'", inside, checkText)
	G.Log.Debug("| HTML is: %s", html)

	rxx := regexp.MustCompile(`^(@[a-zA-Z0-9_-]+\s+)`)
	for {
		if m := rxx.FindStringSubmatchIndex(inside); m == nil {
			break
		} else {
			prefix := inside[m[2]:m[3]]
			inside = inside[m[3]:]
			G.Log.Debug("| Stripping off @prefx: %s", prefix)
		}
	}
	if strings.HasPrefix(inside, checkText) {
		return nil
	}

	return NewProofError(keybase1.ProofStatus_DELETED, "Could not find '%s' in '%s'",
		checkText, inside)
}
开发者ID:polluks,项目名称:client,代码行数:31,代码来源:proof_support_twitter.go

示例4: convertOrderedListSelection

func convertOrderedListSelection(sel *goquery.Selection) {
	handleNestedList(sel)
	setCounter := getListStartCounter(sel)

	indentBeginEnd := strings.Repeat("\t", NEST_DEPTH-1)
	text, _ := sel.Html()
	left := indentBeginEnd + "\\begin{enumerate}\n" + setCounter + "\t\\itemsep0em"
	right := indentBeginEnd + "\\end{enumerate}"
	sel.ReplaceWithHtml(wrap(text, left, right))
}
开发者ID:frankMilde,项目名称:rol,代码行数:10,代码来源:list.go

示例5: convertUnorderedListSelection

func convertUnorderedListSelection(sel *goquery.Selection) {
	handleNestedList(sel)
	setCounter := getListStartCounter(sel)

	//	indentItems := strings.Repeat("\t", NEST_DEPTH)
	indentBeginEnd := strings.Repeat("\t", NEST_DEPTH-1)

	text, _ := sel.Html()
	//text = strdel.LeadingSpaces(text)
	left := indentBeginEnd + "\\begin{itemize}\n" + setCounter + "\t\\itemsep0em"
	right := indentBeginEnd + "\\end{itemize}"
	sel.ReplaceWithHtml(wrap(text, left, right))
}
开发者ID:frankMilde,项目名称:rol,代码行数:13,代码来源:list.go

示例6: printSelectionHtmlWithTitle

func printSelectionHtmlWithTitle(title string, sel *goquery.Selection) {
	html, _ := sel.Html()
	Debug("%v selection: %v", title, html)
}
开发者ID:frankMilde,项目名称:rol,代码行数:4,代码来源:html2tex.go

示例7: printSelectionHtml

func printSelectionHtml(sel *goquery.Selection) {
	html, _ := sel.Html()
	Debug("selection: %v", html)
}
开发者ID:frankMilde,项目名称:rol,代码行数:4,代码来源:html2tex.go

示例8:

						}
					} else if h2s := query.Find("h2"); len(h2s.Nodes) != 0 {
						for i := 0; i < len(h2s.Nodes); i++ {
							info = findP(h2s.Eq(i))
						}
					} else if h3s := query.Find("h3"); len(h3s.Nodes) != 0 {
						for i := 0; i < len(h3s.Nodes); i++ {
							info = findP(h3s.Eq(i))
						}
					} else {
						info = query.Find("body")
					}
					// 去除标签
					// info.RemoveFiltered("script")
					// info.RemoveFiltered("style")
					infoStr, _ := info.Html()

					// 清洗HTML
					infoStr = CleanHtml(infoStr, 5)

					// 结果存入Response中转
					resp.AddItem(map[string]interface{}{
						self.GetOutFeild(resp, 0): title,
						self.GetOutFeild(resp, 1): resp.GetTemp("description"),
						self.GetOutFeild(resp, 2): infoStr,
						self.GetOutFeild(resp, 3): resp.GetTemp("releaseTime"),
						self.GetOutFeild(resp, 4): resp.GetTemp("src"),
						self.GetOutFeild(resp, 5): resp.GetTemp("author"),
					})
				},
			},
开发者ID:zydudu,项目名称:pholcus,代码行数:31,代码来源:baidunews.go


注:本文中的github.com/PuerkitoBio/goquery.Selection.Html方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。