import java.util.regex.*; import java.io.*; import java.util.*; import java.net.*; public class FindURLs2 { private void getLinksFromURL(String url) { try { BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream() ) ); Pattern p = Pattern.compile("href.*?http://(.*?)\"*>", Pattern.CASE_INSENSITIVE); String line; while((line = in.readLine()) != null) { Matcher m = p.matcher(line); while (m.find()) { System.out.println(m.group(1)); } } in.close(); } catch (IOException e) { System.err.println(e); System.exit(0); } } public static void main(String[] args) { FindURLs2 f = new FindURLs2(); f.getLinksFromURL(args[0]); } }