add mikami command

This commit is contained in:
Yasuhiro Matsumoto 2017-04-27 00:56:28 +09:00
parent 3fb35ec728
commit b1ec2978a2
2 changed files with 31 additions and 0 deletions

26
cmd/mstdn/cmd_mikami.go Normal file
View File

@ -0,0 +1,26 @@
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
}

View File

@ -280,6 +280,11 @@ func makeApp() *cli.App {
Usage: "initialize profile", Usage: "initialize profile",
Action: func(c *cli.Context) error { return nil }, Action: func(c *cli.Context) error { return nil },
}, },
{
Name: "mikami",
Usage: "search mikami",
Action: cmdMikami,
},
} }
app.Setup() app.Setup()
return app return app