surf icon indicating copy to clipboard operation
surf copied to clipboard

How do I post the captcha info?

Open eminol opened this issue 7 years ago • 4 comments

How do I post the captcha info?

eminol avatar Mar 22 '18 18:03 eminol

The whole point of captchas are to prevent spam from programs that are made with things like surf. what captchas are you looking to complete? The only one i can think of doing with this are those simple ones that make you add two numbers

Noy avatar Mar 23 '18 09:03 Noy

I want to show to user to captcha in website. User will enter information on captcha. I will make it automatically perform the actions on the site.

Below is the sample code. I'm entering captcha information. But it gives an error.

Best Regards.

//--------------------------------------------------------------------------------- package main

import ( "fmt" "github.com/headzoo/surf" "path/filepath" "os" "log" "github.com/headzoo/surf/browser" ) //--------------------------------------------------------------------------------- func main() { bow := surf.NewBrowser() err := bow.Open("https://medeczane.sgk.gov.tr/eczane") if err != nil { panic(err) } // Download the images on the page and write them to files. frms:=bow.Forms()

frm:=frms[1]
frm.Input("j_username",	"zzzzzzz")
frm.Input("j_password",	"ppppp")
for _, img:= range bow.Images() {
	if right(img.URL.Path,26)=="SayiUretenImageYeniServlet" {
		saveCaptcha(img)
		continue
	}
}
dz:="Login Captcha: "
fmt.Print(dz)
    //Input Captcha Inofrmation
fmt.Scanln(&dz)
frm.Input("guvenlikNumarasi",	dz)
frm.Submit()

println(bow.Body())

} //--------------------------------------------------------------------------------- func right (dz string, num int) string{ strLen :=len(dz) if strLen < num { return dz } return dz[strLen-num:] } //--------------------------------------------------------------------------------- func saveCaptcha(img *browser.Image) { fileName, _ := filepath.Abs(filepath.Dir(os.Args[0])) fileName = fileName + "/captcha.png" fs, err := os.Create(fileName) if err != nil { log.Printf( "Error create file '%s'.", fileName) panic(err) } defer fs.Close() //Resmi yükle _, err = img.Download(fs) if err != nil { log.Printf( "Error create file '%s'.", fileName) panic(err) } } //---------------------------------------------------------------------------------

eminol avatar Mar 25 '18 10:03 eminol

Have you tried printing the value of dz and returning the length to make sure there is no white spaces or new line characters?

Might be worth checking err for your inputs as well to make sure you are filling out the correct fields.

Joffcom avatar Mar 26 '18 06:03 Joffcom

The captcha value you attach to the site changing during the download phase. It behaving like a different session.

eminol avatar Mar 26 '18 11:03 eminol