如SLaks的评论所述,您可能缺少一些cookie。
这是提供的网址的工作示例:
// Load the initial page for getting the required cookiesConnection conn = Jsoup.connect("https://www.saes.upiicsa.ipn.mx/");document d = conn.get();Element captcha = d.select("#c_default_ctl00_leftcolumn_loginuser_logincaptcha_CaptchaImage").first();if (captcha == null) { throw new RuntimeException("Unable to find captcha...");}// Fetch the captcha imageConnection.Response response = Jsoup // .connect(captcha.absUrl("src")) // Extract image absolute URL .cookies(conn.response().cookies()) // Grab cookies .ignoreContentType(true) // Needed for fetching image .execute();// Load image from Jsoup responseImageIcon image = new ImageIcon(ImageIO.read(new ByteArrayInputStream(response.bodyAsBytes())));// Show imageJOptionPane.showMessageDialog(null, image, "Captcha image", JOptionPane.PLAIN_MESSAGE);


