trip attr
(doc *goquery.Document)
| 94 | |
| 95 | // trip attr |
| 96 | func trimAttr(doc *goquery.Document) *goquery.Document { |
| 97 | attrs := []string{ |
| 98 | "border", "colspan", "rowspan", "style", "cellspacing", |
| 99 | "cellpadding", "bgcolor", "width", "align", "frame", "id", "class", |
| 100 | } |
| 101 | elements := []string{ |
| 102 | "table", "thead", "tbody", "tr", "td", "th", "h1", "h2", "h3", "h4", "img", |
| 103 | "h5", "h6", "i", "em", "strong", "span", "br", "hr", "ul", "li", "ol", |
| 104 | } |
| 105 | elements = append(elements, blockTag...) |
| 106 | elements = append(elements, nextlineTag...) |
| 107 | for _, tag := range elements { |
| 108 | doc.Find(tag).Each(func(i int, selection *goquery.Selection) { |
| 109 | for _, attr := range attrs { |
| 110 | selection.RemoveAttr(attr) |
| 111 | } |
| 112 | }) |
| 113 | } |
| 114 | return doc |
| 115 | } |
| 116 | |
| 117 | //压缩html |
| 118 | func compress(doc *goquery.Document) (*goquery.Document, map[string]string) { |