Conversation
thyagopereira
commented
Apr 27, 2021
- 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.
crawler.go
Outdated
| page, err := ioutil.ReadAll(resp.Body) | ||
| htmlCode := string(page) | ||
|
|
||
| id := strings.Split(htmlCode, "Constants.viewingSessionId = \"") |
There was a problem hiding this comment.
Poderia, por favor, fazer um teste de unidade para essa função? para tornar o teste mais fácil, pode utilizar a bilioteca httptest
danielfireman
left a comment
There was a problem hiding this comment.
Estamos quase chegando lá! 😄
|
|
||
| // 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=") |
There was a problem hiding this comment.
Aplicar o mesmo estilo da sugestão abaixo aqui.
danielfireman
left a comment
There was a problem hiding this comment.
Bacana! Favor endereçar os comentários abaixo antes de fazer merge
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| _, err = os.Stat(outputPath) |
There was a problem hiding this comment.
colocar esse assinalamento no if abaixo
| var fileName = fmt.Sprintf("%d_%02d_remu.xls", year, month) | ||
| var filePath = fmt.Sprint(outputPath, "/", fileName) | ||
|
|
||
| err = download(request.remunerationURL, filePath, outputPath) |
There was a problem hiding this comment.
Colocar esse assinalamento no if abaixo
| var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month) | ||
| var filePath = fmt.Sprint(outputPath, "/", fileName) | ||
|
|
||
| err = download(request.benefitsURL, filePath, outputPath) |
There was a problem hiding this comment.
mover assinalamento para dentro do if abaixo
| 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"` |
| fileNames := Crawl(month, year, outputPath) | ||
| fileNames, err := Crawl(month, year, outputPath) | ||
| if err != nil { | ||
| os.Exit(1) |
|
|
||
| paths = append(paths, filePath) | ||
| case viURLType: | ||
| var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month) |
There was a problem hiding this comment.
| var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month) | |
| fileName := fmt.Sprintf("%d_%02d_vi.xls", year, month) |
| paths = append(paths, filePath) | ||
| case viURLType: | ||
| var fileName = fmt.Sprintf("%d_%02d_vi.xls", year, month) | ||
| var filePath = fmt.Sprint(outputPath, "/", fileName) |
There was a problem hiding this comment.
| var filePath = fmt.Sprint(outputPath, "/", fileName) | |
| filePath := fmt.Sprint(outputPath, "/", fileName) |