Open eminol opened 6 years ago
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
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) } } //---------------------------------------------------------------------------------
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.
The captcha value you attach to the site changing during the download phase. It behaving like a different session.
How do I post the captcha info?