Skip to content

Mpro coleta - #5

Open
thyagopereira wants to merge 5 commits into
mainfrom
mpro_coleta
Open

Mpro coleta#5
thyagopereira wants to merge 5 commits into
mainfrom
mpro_coleta

Conversation

@thyagopereira

Copy link
Copy Markdown
Contributor
  • Criação do file só acontece com sudo, trabalhando nisso.
  • Avanços estruturais, e de coleta. Me atrasou um pouco a necessidade de lidar com o id de sessão.

Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go
Comment thread crawler.go
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
page, err := ioutil.ReadAll(resp.Body)
htmlCode := string(page)

id := strings.Split(htmlCode, "Constants.viewingSessionId = \"")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poderia, por favor, fazer um teste de unidade para essa função? para tornar o teste mais fácil, pode utilizar a bilioteca httptest

Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread main.go
Comment thread crawler.go Outdated
Comment thread crawler.go
Comment thread crawler.go
Comment thread crawler.go Outdated
Comment thread crawler.go
Comment thread crawler.go Outdated
Comment thread main.go

@danielfireman danielfireman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Estamos quase chegando lá! 😄

Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go Outdated
Comment thread crawler.go
Comment thread crawler.go

// Retorna as url para download de cada planilha em questão
func requestURL(year, month int) (urlRequests, error) {
remuIDURL := fmt.Sprint("https://servicos-portal.mpro.mp.br/plcVis/frameset?__report=..%2FROOT%2Frel%2Fcontracheque%2Fmembros%2FremuneracaoMembrosAtivos.rptdesign&anomes=", year, fmt.Sprintf("%02d", month), "&nome=&cargo=&lotacao=")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aplicar o mesmo estilo da sugestão abaixo aqui.

@danielfireman danielfireman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bacana! Favor endereçar os comentários abaixo antes de fazer merge

Comment thread crawler.go
}
defer resp.Body.Close()

_, err = os.Stat(outputPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colocar esse assinalamento no if abaixo

Comment thread crawler.go
var fileName = fmt.Sprintf("%d_%02d_remu.xls", year, month)
var filePath = fmt.Sprint(outputPath, "/", fileName)

err = download(request.remunerationURL, filePath, outputPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colocar esse assinalamento no if abaixo

Comment thread crawler.go
var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)
var filePath = fmt.Sprint(outputPath, "/", fileName)

err = download(request.benefitsURL, filePath, outputPath)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mover assinalamento para dentro do if abaixo

Comment thread main.go
Month int `envconfig:"MONTH" required:"true"`
Year int `envconfig:"YEAR" required:"true"`
OutputFolder string `envconfig:"OUTPUT_FOLDER" default:"/output"`
OutputFolder string `envconfig:"OUTPUT_FOLDER" default:"./output"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remover "."

Comment thread main.go
fileNames := Crawl(month, year, outputPath)
fileNames, err := Crawl(month, year, outputPath)
if err != nil {
os.Exit(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usar pacote status

Comment thread crawler.go

paths = append(paths, filePath)
case viURLType:
var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)
fileName := fmt.Sprintf("%d_%02d_vi.xls", year, month)

Comment thread crawler.go
paths = append(paths, filePath)
case viURLType:
var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month)
var filePath = fmt.Sprint(outputPath, "/", fileName)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var filePath = fmt.Sprint(outputPath, "/", fileName)
filePath := fmt.Sprint(outputPath, "/", fileName)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usar filepath.Join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants