I am using curl to do a user simulation login, but encountered a verification code. I found a lot of information on the Internet, but I didn't solve the problem. I think the idea of trying to simulate a login is something like this:
1, get the form on the page, simulate fill in the login name and password;
2, from the verification code picture to obtain the verification Code, simulation fill in the Verification code; (This step to obtain the verification code can not solve)
3. Submit cookies and parameters to log in and save local cookies;
Where the 2nd step encountered a problem, how will the verification code? Do you use the image recognition library? Or download let the user manually input it? Or is there another way?
Hope to do this kind of needs of friends to help, thank you ~
Reply content:
I am using curl to do a user simulation login, but encountered a verification code. I found a lot of information on the Internet, but I didn't solve the problem. I think the idea of trying to simulate a login is something like this:
1, get the form on the page, simulate fill in the login name and password;
2, from the verification code picture to obtain the verification Code, simulation fill in the Verification code; (This step to obtain the verification code can not solve)
3. Submit cookies and parameters to log in and save local cookies;
Where the 2nd step encountered a problem, how will the verification code? Do you use the image recognition library? Or download let the user manually input it? Or is there another way?
Hope to do this kind of needs of friends to help, thank you ~
Speedy answer
- Manual input
- Spend money on online coding of API online
- OCR (inaccurate, simple captcha can be, but generally not expected)
You can go to www.uuwise.com such a website, to understand the verification code coding Black Technology
- If you manually code, with PHP with a cookie to verify the value of the code, and then set
Header("Content-Type: image/jpeg"); spit, here you can combine the front-end to make small improvements, such as the Ajax Long poll or WebSocket to do a real-time reminder of the little thing, once the new verification code is generated, Your client ding-dong prompts you to hit the verification code, finishes, passes the content to the Curl class, and curl simulates you passing the verification code to the website. In PHP There is a very powerful simulation library, called snoopy.class.php .
- If the verification code is relatively simple (no distortion, no interference line, non-Chinese, character length is fixed length, each code character boundary distance is equal, noise is small, the font is not uncommon or you can find), that is, you think the machine can be identified according to a certain pattern, then you write an OCR with PHP, or call the extension, I don't know if there are any OCR extensions you can look for yourself. Write their own simple, I remember is the picture two, and then the area of each letter split, calculate the proportion of black, and has a font library comparison, online similar tutorial too much, their own practice.
http://blog.csdn.net/ugg/article/details/3972368
Http://jingyan.baidu.com/article/456c463b66e5320a583144b7.html
Http://www.poboke.com/study/php-verification-code-identification-primary.html