Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. package instagramPicture;
  2.  
  3. import java.io.IOException;
  4. import java.net.MalformedURLException;
  5. import java.net.URL;
  6. import java.util.Scanner;
  7.  
  8. import javax.swing.JOptionPane;
  9. import javax.swing.JTextArea;
  10.  
  11. import com.sun.xml.internal.ws.Closeable;
  12.  
  13. public class getUrl {
  14. public String z(String s) throws IOException{
  15. URL url = new URL(s);
  16. Scanner scn = new Scanner(url.openStream());
  17. String line;
  18. while(scn.hasNext()){
  19. line = scn.nextLine();
  20. if(line.contains("og:image")&&line.contains("?ig_cache_key")){
  21. line = line.substring(line.indexOf("og:image")+19,line.indexOf("?ig_cache_key"));
  22. return line;
  23. }
  24. }
  25. return "Чего-то я там ничего не нашёл";
  26. }
  27.  
  28. public static void main(String[] args){
  29. int a = 1;
  30. while(a==1){
  31. try{
  32. String s = JOptionPane.showInputDialog("Вставь сюда ссылку с инсты. \n открой картинку и скопируй всё из адресной строки");
  33. s = new getUrl().z(s);
  34. JTextArea ta = new JTextArea();
  35. ta.setText(s);
  36. ta.setEditable(false);
  37. a--;
  38. JOptionPane.showMessageDialog(null, ta);
  39. }catch (Exception e){
  40. JOptionPane.showMessageDialog(null, "Что-то не так. Может, нет интернета? Или ты долбоёб и не вставил ссылку?\n Вставь ссылку, пидор, иначе не закроешь окно");
  41. }
  42.  
  43. }
  44.  
  45.  
  46.  
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement