简体   繁体   中英

Get image for captcha session

I want to get the current captcha that is displayed on a website. An example of this would be http://top100arena.com/in.asp?id=58978

How would I get the image link of the captcha that is displayed other than right clicking - > open image in new page?

You are looking for the div identified by "rechapta_image" : 在此处输入图片说明

Then extract the src attribute of the img element inside this div.

To do this, you can choose for an easy String-operation-based way or use a HTML parsing library like JSoup .

Here is an example of such an extract URL:

http://www.google.com/recaptcha/api/image?c=03AHJ_VutGj3wvhGoQGxu6FUnG3uOWJdyB2RpSb2N5v9AQJyakMy1kKMPeDoRfADhjAj5rLqekuOzXe3cRChnA_sEN7PL68em4pI_kE3wFKUhhkqFF9jQzKJerX__InwD_DB0Ox1mKQmZVRl97yuSL62tZhYyhSqtuIta-3n0KvytB9QqSn8nXgw8


Actually, it seems that the chapta box is an iframe. So search for an iframe with src string containing "chapta". Example of such a iframe:

<iframe src="http://www.google.com/recaptcha/api/noscriptk=6LeyFroSAAAAAJTmR7CLZ5an7pcsS5eJ3wEoWHhJ"
   height="300" width="500" frameborder="0"></iframe><br/>

So, once you extracted that URL, use JSoup again to find the URL to the image. The page fetched has a part this:

在此处输入图片说明

So, look for a center element, and get the img element out of it.

尝试在firefox https://addons.mozilla.org/es/firefox/addon/firebug/中使用Firebug,它易于使用,在红色部分中,您将找到一个名为Image的标签,您将在其中找到该图像。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM