Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Selenium processing of CAPTCHA

Shulou Source: shulou.com Published: 2022-06-03 06:21:46 11月23日 Update

Selenium-CAPTCHA processing

1.WEB website adds the function of CAPTCHA in order to prevent clients from maliciously.

The common method for 2.selenium to deal with CAPTCHA is through cooike. For general websites, CAPTCHA is not difficult to identify. You can use the third-party platform CAPTCHA interface. Take Qunar as an example, CAPTCHA is a picture, and we just need to save the picture.

Call a third-party platform.

Http://wiki.ruokuai.com/ downloads the java interface document and calls the following API directly

Public static String createByPost (String username, String password, String typeid, String timeout, String softid, String softkey, String filePath) {String result = ""; String param = String.format ("username=%s&password=%s&typeid=%s&timeout=%s&softid=%s&softkey=%s", username, password, typeid, timeout, softid, softkey) Try {File f = new File (filePath); if (null! = f) {int size = (int) f.length (); byte [] data = new byte [size]; FileInputStream fis = new FileInputStream (f); fis.read (data, 0, size); if (null! = fis) fis.close () If (data.length > 0) result = RuoKuai.httpPostImage ("http://api.ruokuai.com/create.txt", param, data);}} catch (Exception e) {result =" unknown problem ";} return result;}

Example:

First take a screenshot of the CAPTCHA and save it to the project path

Getting ER7C is the verification code.

Tags: Authentication interface processing picture platform third party website small function customer client malicious screenshot document method path problem difficulty project Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Apple Redmi Shulou Technology Huawei