This commit is contained in:
Alex Yatskov 2016-01-08 22:19:36 +09:00
parent 51d16713f3
commit 25965e83d8

View File

@ -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 {