Created
September 13, 2019 02:11
-
-
Save juanhuttemann/15c4adc9a01f1e15d8d868e02d3f6d65 to your computer and use it in GitHub Desktop.
Datos de Asegurado de IPS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "net/url" | |
| "strings" | |
| "time" | |
| "golang.org/x/net/html" | |
| ) | |
| func main() { | |
| start := time.Now() | |
| response, err := http.PostForm( | |
| "http://servicios.ips.gov.py/consulta_asegurado/comprobacion_de_derecho_externo.php", | |
| url.Values{ | |
| "nro_cic": {"2337862"}, | |
| "envio": {"ok"}, | |
| "recuperar": {"Recuperar"}, | |
| }, | |
| ) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer response.Body.Close() | |
| z := html.NewTokenizer(response.Body) | |
| content := []string{} | |
| for z.Token().Data != "html" { | |
| tt := z.Next() | |
| if tt == html.StartTagToken { | |
| t := z.Token() | |
| if t.Data == "td" { | |
| inner := z.Next() | |
| if inner == html.TextToken { | |
| text := (string)(z.Text()) | |
| t := strings.TrimSpace(text) | |
| content = append(content, t) | |
| } | |
| } | |
| } | |
| } | |
| fmt.Println(content[4:]) | |
| fmt.Println(time.Since(start)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment