Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package instagramPicture;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- import javax.swing.JTextArea;
- import com.sun.xml.internal.ws.Closeable;
- public class getUrl {
- public String z(String s) throws IOException{
- URL url = new URL(s);
- Scanner scn = new Scanner(url.openStream());
- String line;
- while(scn.hasNext()){
- line = scn.nextLine();
- if(line.contains("og:image")&&line.contains("?ig_cache_key")){
- line = line.substring(line.indexOf("og:image")+19,line.indexOf("?ig_cache_key"));
- return line;
- }
- }
- return "Чего-то я там ничего не нашёл";
- }
- public static void main(String[] args){
- int a = 1;
- while(a==1){
- try{
- String s = JOptionPane.showInputDialog("Вставь сюда ссылку с инсты. \n открой картинку и скопируй всё из адресной строки");
- s = new getUrl().z(s);
- JTextArea ta = new JTextArea();
- ta.setText(s);
- ta.setEditable(false);
- a--;
- JOptionPane.showMessageDialog(null, ta);
- }catch (Exception e){
- JOptionPane.showMessageDialog(null, "Что-то не так. Может, нет интернета? Или ты долбоёб и не вставил ссылку?\n Вставь ссылку, пидор, иначе не закроешь окно");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement