I make a program that works through the VK API.

Periodically VK gives captcha. I'm going to automatically recognize it with the help of a special service where you need to send a base64 encoded captcha image.

VK API gives out a link of this type https://api.vk.com/captcha.php?sid=656102463982&s=1

On this page there is already a captch in base64 (you can see it in Google Chrome browser - press F12 and there are Sources).

How to get it as a string for onward transmission?

I tried to send a GET request at https://api.vk.com/captcha.php?sid=656102463982&s=1

Some kind of porridge comes in response (on the screen, it’s not even copied normally). Answer

What kind of answer is that and how to continue working with it?

    1 answer 1

    So I figured it out myself. Just get the picture in this way.

    static String URL = "https://api.vk.com/captcha.php?sid=656102463982&s=1"; static Image loadImage() { try { String fileName = "1.jpeg"; BufferedImage img = ImageIO.read(new URL(URL)); File file = new File(fileName); if (!file.exists()) { file.createNewFile(); } ImageIO.write(img, "jpeg", file); return img; } catch (Exception e) { e.printStackTrace(); } return null; } 

    Well, after that it can be encoded and sent for recognition. You don’t even have to write to the disk, it’s done for the test.