Xjasz
Xjasz

Reputation: 1248

Java Android Image CAPTCHA

I'm having trouble with craigslist's login CAPTCHA. My program is trying to display the CAPTCHA image from the html source code. Any one know how you can get the CAPTCHA image link out of the source code? This is the script in their source code that displays the CAPTCHA. I can use there link and load another CAPTCHA and get that image, but what is need is the CAPTCHA image that is currently displayed. I can't find it though.

I know how to display it and everything I just need to find it.

//<![CDATA[
var RecaptchaOptions = {"tabindex":1,"theme":"clean"};
//]]>
</script>
<script src="https://www.google.com/recaptcha/api/challenge?
k=6Lf5YAcAAAAAAILdm73fp007vvmaaDpFb6A5HLJP" type="text/javascript"></script>

<noscript><iframe frameborder="0" height="300" 
src="https://www.google.com/recaptcha/api/noscript?
k=6Lf5YAcAAAAAAILdm73fp007vvmaaDpFb6A5HLJP" width="500"></iframe><br><textarea 
cols="40" name="recaptcha_challenge_field" rows="3"></textarea><input 
name="recaptcha_response_field" type="hidden" value="manual_challenge" /></noscript>
</p>

Upvotes: 5

Views: 1447

Answers (1)

niranjan94
niranjan94

Reputation: 826

You can use a Java HTML DOM Parser library. I Recommend jsoup: Java HTML Parser.

  • Download the Library file from here and copy it into the libs folder of your android project.

Then you can use the following code to get the image site url

Document doc = Jsoup.parse(htmlString);
Element CaptchaFrame = doc.select("noscript > iframe").first();
String CpatchaImageUrl=CaptchaFrame.attr("src");
  • Now you can use that url as a source for an android WebView

Upvotes: 1

Related Questions