diff options
| author | Shulhan <m.shulhan@gmail.com> | 2020-04-05 15:19:10 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2020-04-05 15:19:10 +0700 |
| commit | 826f56cf7ea4ca350078538d39fd6fee6f05bf9a (patch) | |
| tree | 2211e5051c97369557811b9e290edd381375ffdb /parser.go | |
| parent | 3061f6561c746f216586c271a10219515dcdb2d7 (diff) | |
| download | kamusku-826f56cf7ea4ca350078538d39fd6fee6f05bf9a.tar.xz | |
all: simplify html parser using github.com/shuLhan/share/lib/net/html
Diffstat (limited to 'parser.go')
| -rw-r--r-- | parser.go | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/parser.go b/parser.go deleted file mode 100644 index 8a66e6f..0000000 --- a/parser.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2020, Shulhan <m.shulhan@gmail.com>. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package kbbi - -import ( - "strings" - - "golang.org/x/net/html" -) - -func getAttrValue(attrs []html.Attribute) string { - for _, attr := range attrs { - if attr.Key == attrNameValue { - return attr.Val - } - } - return "" -} - -// -// getFirstChild get the first non-empty child. -// -func getFirstChild(node *html.Node) *html.Node { - el := node.FirstChild - for el != nil { - if el.Type == html.TextNode { - if len(strings.TrimSpace(el.Data)) == 0 { - el = el.NextSibling - continue - } - } - break - } - return el -} - -func getNextSibling(node *html.Node) *html.Node { - el := node.NextSibling - for el != nil { - if el.Type == html.TextNode { - if len(strings.TrimSpace(el.Data)) == 0 { - el = el.NextSibling - continue - } - } - break - } - return el -} |
