Skip to content

Commit

Permalink
Primeiro commit com vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfireman committed Aug 20, 2018
1 parent 38fc417 commit 9b61d24
Show file tree
Hide file tree
Showing 763 changed files with 184,037 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"


[[constraint]]
name = "github.com/PuerkitoBio/goquery"
version = "1.4.1"
71 changes: 71 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package main

import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
"sync"

"github.com/PuerkitoBio/goquery"
)

var (
pairsFlag = flag.String("p", "", "")
out = flag.String("out", "", "")
)

const (
basePath = "http://www.cnj.jus.br"
remuneracaoPath = "http://www.cnj.jus.br/transparencia/remuneracao-dos-magistrados/remuneracao-"
)

func main() {
flag.Parse()

pairs := strings.Split(*pairsFlag, ",")
var wg sync.WaitGroup
for _, p := range pairs {
remuneracaoURL := fmt.Sprintf("%s%s", remuneracaoPath, p)
doc, err := goquery.NewDocument(remuneracaoURL)
if err != nil {
log.Fatal(err)
}
doc.Find("td").Each(func(index int, item *goquery.Selection) {
linkTag := item.Find("a")
link, _ := linkTag.Attr("href")
if strings.HasSuffix(link, "xls") || strings.HasSuffix(link, "xlsx") {
wg.Add(1)
go func() {
defer wg.Done()
dLink := fmt.Sprintf("%s%s", basePath, link)
resp, err := http.Get(dLink)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
outPath := filepath.Join(*out, fmt.Sprintf("%s-%s", p, filepath.Base(dLink)))
f, err := os.Create(outPath)
defer f.Close()
if err != nil {
log.Fatal(err)
}
w := bufio.NewWriter(f)
w.Write(b)
w.Flush()
fmt.Printf("%s downloaded to %s\n", dLink, outPath)
}()
}
})
}
wg.Wait()
}
1 change: 1 addition & 0 deletions vendor/github.com/PuerkitoBio/goquery/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions vendor/github.com/PuerkitoBio/goquery/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/PuerkitoBio/goquery/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vendor/github.com/PuerkitoBio/goquery/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

177 changes: 177 additions & 0 deletions vendor/github.com/PuerkitoBio/goquery/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b61d24

Please sign in to comment.