func ParseItem(r io.Reader) { t, _ := transform.NewFromReader(r) t.Apply(transform.Replace(), "script") t.Apply(transform.Replace(), "footer") t.Apply(transform.Replace(), "meta") t.Apply(transform.Replace(), "ul") t.Apply(transform.Replace(), "li") t.Apply(transform.Replace(), "link") t.Apply(transform.Replace(), "div.day") t.Apply(transform.Replace(), "div.advent-calendar-breadcrumb") t.Apply(transform.Replace(), "a.post-user-icon") fmt.Println(t.String()) }
func ParseItem(r io.Reader) { // transformのインスタンスを作る t, _ := transform.NewFromReader(r) // Applyメソッドで自分のDOMに反映する。 // Applyメソッド内では、TransformFuncを受け付けるようになっており、 // Replaceの他にもDOMを追加するAppendChildrenやPrependChildrenなどもある。 // ページを加工するならこっちのが便利。 // ちなみに以下の処理で不要なページを削っている t.Apply(transform.Replace(), "script") t.Apply(transform.Replace(), "footer") t.Apply(transform.Replace(), "meta") t.Apply(transform.Replace(), "ul") t.Apply(transform.Replace(), "li") t.Apply(transform.Replace(), "link") t.Apply(transform.Replace(), "div.day") t.Apply(transform.Replace(), "div.advent-calendar-breadcrumb") t.Apply(transform.Replace(), "a.post-user-icon") fmt.Println(t.String()) }