fork download
  1. package parser2ch;
  2.  
  3. import org.jsoup.Jsoup;
  4. import org.jsoup.nodes.Document;
  5. import org.jsoup.select.Elements;
  6. import java.io.*;
  7. import javax.imageio.*;
  8. import java.net.*;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11. import java.awt.image.BufferedImage;
  12.  
  13. public class Parser2ch {
  14.  
  15.  
  16.  
  17. public static void main(String[] args) {
  18.  
  19. try {
  20. // System.setProperty("http.proxyHost", "103.10.22.242");
  21. //System.setProperty("http.proxyPort", "1080");
  22. String urlThread = "https://2...content-available-to-author-only...h.hk/b/res/103534916.html";
  23. Document doc = Jsoup
  24. .connect(urlThread)
  25. .timeout(5000)
  26. .userAgent("Mozilla/41.0.1")
  27. .get();
  28.  
  29. Elements links = doc.select("a.desktop");
  30. int tick = 1;
  31. for(;tick<links.size();tick++){
  32. String absHref = links.eq(tick).attr("abs:href");
  33. String linkText = links.eq(tick).text();
  34. URL url = new URL(absHref);
  35.  
  36. // read the url
  37. BufferedImage image = ImageIO.read(url.openStream()); // сюда ругается
  38. // проверяеdsм на пусто
  39. if (image != null){
  40.  
  41. try {
  42. ImageIO.write(image, "jpg",new File("D:\\JavaProject\\Parser2ch\\images\\"+linkText)); //сохраняет
  43. Thread.sleep(2000);
  44. System.out.println(tick+" "+linkText+" +");
  45. } catch (InterruptedException ex) {
  46. Logger.getLogger(Parser2ch.class.getName()).log(Level.SEVERE, null, ex);
  47. System.out.println(tick+" "+linkText+" -");
  48. }
  49.  
  50. }
  51. }
  52. } catch (IOException ex) {
  53. Logger.getLogger(Parser2ch.class.getName()).log(Level.SEVERE, null, ex);
  54. }
  55.  
  56.  
  57. }
  58.  
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:13: error: class Parser2ch is public, should be declared in a file named Parser2ch.java
public class Parser2ch {
       ^
Main.java:3: error: package org.jsoup does not exist
import org.jsoup.Jsoup;
                ^
Main.java:4: error: package org.jsoup.nodes does not exist
import org.jsoup.nodes.Document;
                      ^
Main.java:5: error: package org.jsoup.select does not exist
import org.jsoup.select.Elements;
                       ^
Main.java:23: error: cannot find symbol
            Document doc = Jsoup
            ^
  symbol:   class Document
  location: class Parser2ch
Main.java:23: error: cannot find symbol
            Document doc = Jsoup
                           ^
  symbol:   variable Jsoup
  location: class Parser2ch
Main.java:29: error: cannot find symbol
            Elements links = doc.select("a.desktop");
            ^
  symbol:   class Elements
  location: class Parser2ch
7 errors
stdout
Standard output is empty