• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How To Read A Web Page

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We use getParameter() to read user input, etc.
My question is how to read the content of an existing web site; say, if I type in xyz.com and I am lead to a web page that is all text. And I want to scan the whole page.
Looking forward to have your guidance.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From a browser - there is usually a "view Source" option
From a program - look at the classes in the java.net package, especially URL, URLConnection and HttpURLConnection. You can open a connection and slurp up the content as an InputStream.
Bill
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can try an example i tried,
--------------
package work_simple;
import java.io.*;
public class FileReaderDemo
{
static String in = "C:\\readme.html";
public static void main(String[] args)
{
try
{
FileReader fr = new FileReader(in);
BufferedReader br= new BufferedReader(fr);
String S;
String Y = "";

while ((S = br.readLine()) != null)
{
Y = Y +" "+ S;
}
System.out.println(Y);
fr.close();
}catch(Exception e)
{
System.out.println("job could not be finished: " + e);
}
System.out.println("job finished");
}

}
--------------
 
You can't have everything. Where would you put it?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic