go-mastodon/cmd/mstdn/cmd_mikami.go
Yasuhiro Matsumoto b1ec2978a2 add mikami command
2017-04-27 00:56:28 +09:00

27 lines
504 B
Go

package main
import (
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/urfave/cli"
)
func cmdMikami(c *cli.Context) error {
doc, err := goquery.NewDocument("http://mastodonsearch.jp/cross/?q=三上")
if err != nil {
return err
}
doc.Find(".post").Each(func(n int, elem *goquery.Selection) {
href, ok := elem.Find(".mst_content a").Attr("href")
if !ok {
return
}
text := elem.Find(".mst_content p").Text()
fmt.Println(href)
fmt.Println(text)
fmt.Println()
})
return nil
}