• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

How to read text content not source code from webpage in java ?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guyz..
How to read text content not source code from webpage using java ?

Thanks,
http://teknoturfian.blogspot.com
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In java.net package we have URLConnection class is there. we can use that to connect to some URL and request and get response from that.
 
Marimuthu Udayakumar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Venkateswara ,
Thanks for your reply,
I tried this,


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;


public class URLExp {

public static void main(String[] args) {
try {
URL google = new URL("http://www.google.com/");
URLConnection yc = google.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc
.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);

}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}

}


BUT...
what happend i can get the source code of the webpage ,I need text based real content.So what i do?...
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marimuthu Udayakumar wrote:BUT...
what happend i can get the source code of the webpage ,I need text based real content.So what i do?...


You'd have to parse the HTML in your program and get the text out of it yourself.
 
Sheriff
Posts: 22250
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And next time, please http://faq.javaranch.com/java/UseCodeTags
 
Marimuthu Udayakumar
Greenhorn
Posts: 16
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jesper Young ,
Thanks for your query,I made it.

Hi Rob Prime,
Thanks for your suggesstion that code Tag, I used that Tag too here...

I used NekoHTML parser ..




I used jar files named nekohtml.jar and xercesImpl.jar for parser ,
I am not able to attach those jarfiles here.just you can download from web,
If you dont get it just mail me to teknoturfian@gmail.com
I will send it to you..
Thanks guys...Have a good day...
http://www.wix.com/muthu_tek/Marimuthu-at-Teknoturf
http://teknoturfian.blogspot.com

" I aim to bring Passion and Quality to every relationship"
 
reply
    Bookmark Topic Watch Topic
  • New Topic