Get image for captcha session

南笙酒味 提交于 2019-12-06 08:19:48

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.

Try using Firebug in firefox https://addons.mozilla.org/es/firefox/addon/firebug/, Its easy to use and in the Red section you´ll find a label named Image, you´ll find the image there.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!