-6

According to my reference, this might work:

URL url = new URL("www.gmail.com");       
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null) {
    tr = in.readLine().toString();
    System.out.println(str);
}
FlexEast
  • 317
  • 2
  • 13

1 Answers1

3

You can use a library like JSoup to get the body text from the HTML.

https://jsoup.org/cookbook/input/parse-body-fragment

String html = "<div><p>Lorem ipsum.</p>";
Document doc = Jsoup.parseBodyFragment(html);
Element body = doc.body();
String text = body.text();
David
  • 7,652
  • 21
  • 60
  • 98