首先我先聲明并無惡意踊挠,僅因為學習使用
package main
import (
"fmt"
"log"
"github.com/PuerkitoBio/goquery"
)
func GetJokes() {
doc, err := goquery.NewDocument("https://www.saikr.com/a/2669")
if err != nil {
log.Fatal(err)
}
dtitle := doc.Find("title").Text()
fmt.Println("標題:" + dtitle)
keywords, _ := doc.Find("meta[name=keywords]").Attr("content")
fmt.Println("關鍵字:" + keywords)
description, _ := doc.Find("meta[name=description]").Attr("content")
fmt.Println("文章描述內容:" + description)
doc.Find(".sk-circle4-1-para-box").Find("div.para").Each(func(index int, sel *goquery.Selection) {
fmt.Println(sel.Text())
})
}
func main() {
GetJokes()
}