Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Selenium processing of CAPTCHA

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report