From f77a48fb7bb8032974945f2d23fa10fcfa64afd2 Mon Sep 17 00:00:00 2001 From: "daniel_fillol@hotmail.com" <55287657+DanielFillol@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:18:07 -0300 Subject: [PATCH 1/2] feat: more direct Crawler func --- goSpider_test.go | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/goSpider_test.go b/goSpider_test.go index 75abd72..bde42b4 100644 --- a/goSpider_test.go +++ b/goSpider_test.go @@ -197,9 +197,7 @@ func TestParallelRequests(t *testing.T) { } func Crawler(d string) (map[string]string, []map[int]map[string]interface{}, []map[int]map[string]interface{}, error) { - log.Printf("Crawling: %s", d) - - url := "https://esaj.tjsp.jus.br/sajcas/login" + url := "https://esaj.tjsp.jus.br/cpopg/open.do" nav := NewNavigator() defer nav.Close() @@ -209,31 +207,6 @@ func Crawler(d string) (map[string]string, []map[int]map[string]interface{}, []m return nil, nil, nil, err } - usernameSelector := "#usernameForm" - passwordSelector := "#passwordForm" - username := "363.400.878-41" - password := "Remoto123*" - loginButtonSelector := "#pbEntrar" - messageFailedSuccess := "#mensagemRetorno > li" - - err = nav.Login(url, username, password, usernameSelector, passwordSelector, loginButtonSelector, messageFailedSuccess) - if err != nil { - log.Printf("Login error: %v", err) - return nil, nil, nil, err - } - - err = nav.ClickButton("#esajConteudoHome > table:nth-child(7) > tbody > tr > td.esajCelulaDescricaoServicos > a") - if err != nil { - log.Printf("ClickButton error: %v", err) - return nil, nil, nil, err - } - - err = nav.ClickButton("#esajConteudoHome > table:nth-child(3) > tbody > tr > td.esajCelulaDescricaoServicos > a") - if err != nil { - log.Printf("ClickButton error: %v", err) - return nil, nil, nil, err - } - err = nav.CheckRadioButton("#interna_NUMPROC > div > fieldset > label:nth-child(5)") if err != nil { log.Printf("CheckRadioButton error: %v", err) From 70b032f574544bbe5f598bf646402197d67a1292 Mon Sep 17 00:00:00 2001 From: "daniel_fillol@hotmail.com" <55287657+DanielFillol@users.noreply.github.com> Date: Mon, 3 Jun 2024 15:18:37 -0300 Subject: [PATCH 2/2] feat: add a final log to ParallelRequests --- goSpider.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/goSpider.go b/goSpider.go index f4c71f8..a75eb0c 100644 --- a/goSpider.go +++ b/goSpider.go @@ -622,6 +622,8 @@ func ParallelRequests(requests []Requests, numberOfWorkers int, duration time.Du } if k == len(requests)-1 { + l := log.New(os.Stdout, "goSpider: ", log.LstdFlags) + l.Printf("Finished processing %d requests\n", len(requests)) return results, errorOnApiRequests }