Class for extracting html data from a url  
Author Message
Harlin





PostPosted: 2005-4-1 20:51:00 Top

java-programmer, Class for extracting html data from a url Does a class exist in Java that would allow one to extract html data
from a web page url?

thanks,

Harlin Seritt

 
Thomas Fritsch





PostPosted: 2005-4-1 21:55:00 Top

java-programmer >> Class for extracting html data from a url Harlin wrote:
> Does a class exist in Java that would allow one to extract html data
> from a web page url?
>
> thanks,
>
> Harlin Seritt
>
You can get an InputStream from the URL:
URL url = ...
InputStream stream = url.openStream();
and read the HTML data from it.
See also
<http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html#openStream()>

You can also try the higher-level method
URL url = ...
String content = (String) url.getContent();
(But I'm not completely sure, whether you really get a String here.)
See also
<http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html#getContent()>

--
"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

 
kaeli





PostPosted: 2005-4-1 22:26:00 Top

java-programmer >> Class for extracting html data from a url In article <email***@***.com>,
email***@***.com enlightened us with...
> Does a class exist in Java that would allow one to extract html data
> from a web page url?

URLConnection.

Google is your friend. So are the sun tutorials.
http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html

--
 
 
Harlin





PostPosted: 2005-4-2 23:11:00 Top

java-programmer >> Class for extracting html data from a url Thomas,

Thanks! This is exactly what I was looking for. I had a hard time
finding this on Google or even in the Sun docs.

Regards,

Harlin Seritt