@@ -0,0 +1,1180 @@
+import java.net.*;%0D%0Aimport javax.swing.text.html.parser.*;%0D%0Aimport javax.swing.text.html.*;%0D%0Aimport javax.swing.text.*;%0D%0Aimport java.io.*;%0D%0Aimport java.util.*;%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.TreeSet;%0D%0A%0D%0Apublic class RetrievePage extends HTMLEditorKit.ParserCallback %7B%0D%0A%0D%0A%09public static ArrayList%3CString%3E links = new ArrayList%3CString%3E();%0D%0A%0D%0Apublic static void main(String%5B%5D args) throws Exception%7B%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%09URL url = new URL(%22https://stackoverflow.com%22);%0D%0A%0D%0A%09Reader reader = new InputStreamReader((InputStream) url.getContent());%0D%0A%0D%0A%09new ParserDelegator().parse(reader, new Page(), true);%0D%0A%0D%0A%09for(int i = 0; i %3C links.size(); i++) %7B%0D%0A%09%09System.out.println(links.get(i));%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A%0D%0Apublic void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) %7B%0D%0A%0D%0A       if (t == HTML.Tag.A) %7B%0D%0A            String link = null;%0D%0A%0D%0A            Enumeration %3C?%3E attributeNames = a.getAttributeNames();%0D%0A%0D%0A            if (attributeNames.nextElement().equals(HTML.Attribute.HREF))%0D%0A                link = a.getAttribute(HTML.Attribute.HREF).toString();%0D%0A%0D%0A                if(link != null) %7B%0D%0A            %09    links.add(link);%0D%0A%09%09%09    %7D%0D%0A            %7D%0D%0A       %7D%0D%0A%0D%0A%0D%0A%0D%0A   %7D%0D%0A%0D%0A

Add files via upload