Documentation ¶
Index ¶
- Constants
- Variables
- func AddElement2Set(arr *[]string, e string)
- func GenPayload(testStr string, ends []string) []string
- func GenerateXPath(node *html.Node) string
- func IsEscaped(s string) bool
- func MatchBetween(srcBody interface{}, start string, end string, n int) (int, string)
- func Node2Raw(node *html.Node) string
- func RandSafeString(n int) string
- func RandStrFromCharSet(charSet string, n int) string
- func RandomUpperAndLower(s string) string
- func WalkNode(node *html.Node, handler func(node *html.Node)) error
- func Walker(h interface{}, handler func(node *html.Node)) error
- type DiffInfo
- type MatchNodeInfo
- type MatchType
- type OutputPosType
Constants ¶
View Source
const ( StructLarger = "node1 contains node2" StructSmaller = "node2 contains node1" )
Variables ¶
View Source
var Exports = map[string]interface{}{ "Walker": Walker, "CompareHtml": CompareHtml, "GenerateXPath": GenerateXPath, "Find": FindNodeFromHtml, "RandomUpperAndLower": RandomUpperAndLower, "MatchBetween": MatchBetween, }
Functions ¶
func AddElement2Set ¶
func GenPayload ¶
func GenerateXPath ¶
GenerateXPath 根据节点引用生成一个节点的 XPath 路径 Example: ``` xhtml.Walker("<html><body><div>hello</div></body></html>", func(node) { println(xhtml.GenerateXPath(node)) }) ```
func MatchBetween ¶
MatchBetween 从字符串中匹配两个字符串之间的内容,最多匹配 n 个字符,n 为 -1 时不限制 返回匹配到的内容的起始位置与匹配到的内容 Example: ``` xhtml.MatchBetween("123456789", "2", "6", -1) // 2, "345" ```
func RandSafeString ¶
func RandStrFromCharSet ¶
func RandomUpperAndLower ¶
RandomUpperAndLower 返回一个随机大小写的字符串 Example: ``` xhtml.RandomUpperAndLower("target") // TArGeT ```
Types ¶
type DiffInfo ¶
type DiffInfo struct { OriginRaw string FuzzRaw string XpathPos string Reason string Type OutputPosType Node *html.Node }
func CompareHtml ¶
CompareHtml 比较两段 HTML 代码的差异,返回差异的节点信息结构体引用切片与错误 Example: ``` diff, err = xhtml.CompareHtml(html1, html2) ```
type MatchNodeInfo ¶
type MatchNodeInfo struct { Xpath string TagName string MatchNode *html.Node MatchText string Key, Val, Quote string // contains filtered or unexported fields }
func FindNodeFromHtml ¶
func FindNodeFromHtml(htmlRaw interface{}, matchStr string) []*MatchNodeInfo
Find 解析并遍历一段 HTML 代码的每一个节点并找到匹配字符串的节点,返回匹配字符串的节点信息的引用切片 Example: ``` matchInfoRes = xhtml.Find("<html><body><div>hello</div></body></html>", "hello") ```
func (*MatchNodeInfo) IsAttr ¶
func (m *MatchNodeInfo) IsAttr() bool
func (*MatchNodeInfo) IsCOMMENT ¶
func (m *MatchNodeInfo) IsCOMMENT() bool
func (*MatchNodeInfo) IsText ¶
func (m *MatchNodeInfo) IsText() bool
type OutputPosType ¶
type OutputPosType string
const ( Tag OutputPosType = "Tag" Text OutputPosType = "Text" Attr OutputPosType = "Attr" AttrHref OutputPosType = "AttrHref" AttrOnxxx OutputPosType = "AttrOnxxx" )
Click to show internal directories.
Click to hide internal directories.