From 0bbd96e0abe1afa6382e66991171382479c6f938 Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Tue, 9 Oct 2018 09:14:26 +0200 Subject: [PATCH] Handy dandy --- src/aaron-fischer.net/fupin/main.go | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/aaron-fischer.net/fupin/main.go diff --git a/src/aaron-fischer.net/fupin/main.go b/src/aaron-fischer.net/fupin/main.go new file mode 100644 index 0000000..a2c5574 --- /dev/null +++ b/src/aaron-fischer.net/fupin/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "gopkg.in/headzoo/surf.v1" + "os" + "flag" +) + +var username = flag.String("username", "", "pinboard username") +var password = flag.String("password", "", "pinboard password") + +func main() { + flag.Parse() + + bow := surf.NewBrowser() + err := bow.Open("https://pinboard.in/") + if err != nil { + panic(err) + } + + form, formErr := bow.Form("form[name=login]") + if formErr != nil { + panic(formErr) + } + + form.Input("username", *username) + form.Input("password", *password) + if form.Submit() != nil { + panic(err); + } + + err = bow.Open("https://pinboard.in/export/format:xml/") + if err != nil { + panic(err) + } + + bow.Download(os.Stdout) +}