how to get links in html file
sir...i need your help.you had posted a code to get links from file,but at the bottom of code you instructed to pass html file.BUT sir i am reading a link online through the given code and through that link ,i have to get child links .i think your code will help me but what changes i have to made to get my goal..
my goal::::to get links of all child nodes from given link(e.g www .yahoo.com) and download all child links
please help me
Code:
//////////////////////read link online/////////////////////////////////
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
/**
*
*
*/
import java.net.MalformedURLException;
import java.net.URL;
public class Main {
String thisLine;
URL u;
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws Exception {
URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(new InputStreamReader(yahoo
.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
Re: help me..how to get links in html file
Quote:
get links of all child nodes from given link
if you make a method that gets all the links from an HTML page at a URL address, you could call that method repeatedly for each new link it finds.
Re: how to get links in html file
You should use this thread and not continue posting on this very old thread:
http://www.java-forums.org/new-java/...tml#post307560
Re: how to get links in html file
Using regular expressions would probably be the most efficient way. Here's the documentation: Lesson: Regular Expressions (The Java™ Tutorials > Essential Classes)