获取验证码会话的图像 [英] Get image for captcha session

查看:184
本文介绍了获取验证码会话的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取网站上显示的当前验证码。这方面的一个例子是



以下是此类提取网址的示例:



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



<小时>

实际上,似乎chapta框是一个iframe。因此,搜索包含chapta的src字符串的iframe。这样的iframe示例:

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

因此,提取该URL后,再次使用JSoup查找图像的URL。获取的页面包含以下内容:





所以,寻找一个中心元素,并从中获取img元素。


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.

这篇关于获取验证码会话的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆