|
@@ -9,6 +9,7 @@ import (
|
|
|
type Cut struct {
|
|
|
tag *regexp.Regexp
|
|
|
scripttag *regexp.Regexp
|
|
|
+ inputag *regexp.Regexp
|
|
|
styletag *regexp.Regexp
|
|
|
colstag *regexp.Regexp
|
|
|
rowstag *regexp.Regexp
|
|
@@ -27,13 +28,14 @@ func NewCut() *Cut {
|
|
|
//sc, _ := regexp.Compile("\\<script[^\\>]*\\>*[^\\>]+\\</script\\>")
|
|
|
//ss, _ := regexp.Compile("\\<style[^\\>]*\\>*[^\\>]+\\</style\\>")
|
|
|
scs := regexp.MustCompile("<(script|style)[^>]*>[^>]+</(script|style)>")
|
|
|
+ input := regexp.MustCompile(`<\s*input.*value=("|')(.*)("|')/?>(</>)?`)
|
|
|
cols, _ := regexp.Compile(`colspan="\d+"`)
|
|
|
rows, _ := regexp.Compile(`rowspan="\d+"`)
|
|
|
dis, _ := regexp.Compile(`display:none`)
|
|
|
return &Cut{
|
|
|
- tag: t,
|
|
|
- scripttag: scs,
|
|
|
- //styletag: ss,
|
|
|
+ tag: t,
|
|
|
+ scripttag: scs,
|
|
|
+ inputag: input,
|
|
|
colstag: cols,
|
|
|
rowstag: rows,
|
|
|
display: dis,
|
|
@@ -52,7 +54,8 @@ func (c *Cut) ClearHtml(src string) string {
|
|
|
src = c.tag.ReplaceAllStringFunc(src, strings.ToLower)
|
|
|
//清script,style
|
|
|
src = c.scripttag.ReplaceAllString(src, "")
|
|
|
- //
|
|
|
+ //清理input
|
|
|
+ src = c.inputag.ReplaceAllString(src, "$2")
|
|
|
//换结束标签
|
|
|
src = c.tag.ReplaceAllStringFunc(src, func(tmp string) string {
|
|
|
tmp = strings.Replace(tmp, " ", "", -1)
|