Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- String getPublicKey = "\"([^\"]+)\",\"captchaContainer";
- String getChallenge = "challenge : '([^']+)',";
- String baseURL = "http://www.google.com/recaptcha/api/image?c=";
- String backupOption = "\"((http)?s?(://)?(www\\.)?google\\.com/recaptcha/[^\"]+)\"";
- //Obviously, we don't HAVE to create those strings, but just for the sake of making the code cleaner, I made them here.
- WebClient temp = new WebClient();
- //WebClient FTW
- String tempSource = temp.DownloadString(textBox1.Text);
- //Used in case the google image is actually just lying there in the source
- String publicKey = Regex.Match(tempSource, getPublicKey).Groups[1].Value;
- //We need the public key to get the image of the captcha
- if(String.IsNullOrEmpty(publicKey)){
- //If we don't have a public key (probably because they're already showing the image in the source), just try to find the image
- pictureBox1.ImageLocation = Regex.Match(tempSource, backupOption).Groups[1].ToString();
- }else{
- String url = String.Format("{0}{1}", baseURL, Regex.Match(temp.DownloadString(String.Format("http://www.google.com/recaptcha/api/challenge?k={0}", publicKey)), getChallenge).Groups[1].ToString());
- //Now we need the challenge key USING the public key
- //God google, wai you gotta complicate my life?
- pictureBox1.ImageLocation = url;
- //Ta-MOTHERFUCKING-DA
- }
- }
- catch (Exception)
- {
- MessageBox.Show("An error has occured, but I was too lazy to tell you what it is.");
- }
Advertisement
Add Comment
Please, Sign In to add comment