renanbastos93 / crawler-covid19-rs

Crawler to get data values about COVID-19 in state Rio Grande do Sul at Brazil
MIT License
3 stars 0 forks source link

Improve regex to get info in the body #1

Closed renanbastos93 closed 1 year ago

renanbastos93 commented 4 years ago

I feeling that it is possible to improve the regex used in this project, but I don't understand how. Does someone help me?

https://github.com/renanbastos93/crawler-covid19-rs/blob/master/main.go#L28

rgxGraphCities = regexp.MustCompile(`GraphMunicipio.*\n.*,`)
rgxGetJSON     = regexp.MustCompile(`\{.*\}`)
rgxLables      = regexp.MustCompile(`\{labels:.*\],`)
rgxValues      = regexp.MustCompile(`\[[\d\,]+\]`)
rgxCities      = regexp.MustCompile(`\[[\wÀ-ú\"\s\,\]\']+,d`)

body:

new Chart(ctx, {type: 'horizontalBar',data: {labels: [" Porto Alegre", " Bagé", " Canoas", " Caxias do Sul", " Torres", " Lajeado", " Sant'Ana do Livramento", " Ivoti", " Erechim", " São Leopoldo", " Serafina Corrêa", " Capão da Canoa", " Pelotas", " Anta Gorda", " Estância Velha", " Santa Maria", " Rio Grande", " Bento Gonçalves", " Campo Bom", " Alvorada", " Marau", " Paraí", " Dom Pedrito", " Osório", " Passo Fundo", " Rolante", " Cachoeira do Sul", " Canguçu", " Santa Rosa", " Nova Palma", " Piratini", " Garibaldi", " Gravataí", " Dois Irmãos", " Charqueadas", " Estrela", " Carlos Barbosa", " Viamão", " Santo Antônio da Patrulha", " Taquara", " Cerro Grande do Sul", " Eldorado do Sul", " Cruzeiro do Sul", " Santiago", " Sapiranga", " Farroupilha"],datasets: [{data: [133,9,7,6,6,5,4,3,3,3,3,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],backgroundColor: 'rgba(166, 58, 58, 0.8)',borderColor: 'rgba(0,0,0,0.8)',borderWidth: 1}]},
renanbastos93 commented 4 years ago

This PR #2 had an improvement in this issue but I believe that we can improve it further