From 25965e83d8cd4dce2a55b470c94124a07d3d43ba Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 8 Jan 2016 22:19:36 +0900 Subject: [PATCH] Cleanup --- scrawl.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scrawl.go b/scrawl.go index ab87425..1c398b4 100644 --- a/scrawl.go +++ b/scrawl.go @@ -32,6 +32,7 @@ import ( "net/http" "net/url" "os" + "path" "path/filepath" "strings" @@ -49,6 +50,8 @@ func scrape(url, css, attr string) (string, error) { return "", fmt.Errorf("no selection for '%s'", css) } + sel = sel.First() + var res string if len(attr) == 0 { res = sel.Text() @@ -89,12 +92,20 @@ func export(path string, r io.Reader) error { return nil } +func usage() { + fmt.Fprintf(os.Stderr, "Usage: %s [options] conf src\n", path.Base(os.Args[0])) + fmt.Fprintf(os.Stderr, "http://foosoft.net/projects/scrawl/\n\n") + fmt.Fprintf(os.Stderr, "Parameters:\n") + flag.PrintDefaults() +} + func main() { var ( attr = flag.String("attr", "", "attribute to query") verbose = flag.Bool("verbose", false, "verbose output") ) + flag.Usage = usage flag.Parse() if flag.NArg() < 2 {