add mikami command
This commit is contained in:
parent
3fb35ec728
commit
b1ec2978a2
26
cmd/mstdn/cmd_mikami.go
Normal file
26
cmd/mstdn/cmd_mikami.go
Normal 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
|
||||
}
|
|
@ -280,6 +280,11 @@ func makeApp() *cli.App {
|
|||
Usage: "initialize profile",
|
||||
Action: func(c *cli.Context) error { return nil },
|
||||
},
|
||||
{
|
||||
Name: "mikami",
|
||||
Usage: "search mikami",
|
||||
Action: cmdMikami,
|
||||
},
|
||||
}
|
||||
app.Setup()
|
||||
return app
|
||||
|
|
Loading…
Reference in New Issue
Block a user