Hi Friends , to day i am going to tell you about
how to read web page problematically
For example if you want to read the data from a web page that contains important data
like exam results on the prices of the products
It will be very difficult to get the look the web page and manually save the data
so i created a program that read the data from the web page and save the data in the text file
---------------------------------------------------------------------------------
Go to example i am getting the data from JNTUK university results site of MCA results
you need to copy the url that shows the marks in the web page and insert in the url instance
Actually the program is taken from oracle.com and i modified to my requirement
i done it in jsp using tomcat server and here is the code
------------------------------------------------------------------------------------------
<%@ page language="java" import="java.io.*,java.net.*" session="true"
buffer="100kb" %>
<%
try
{
URL yahoo = new URL("http://results.jntuk.edu.in/result/testhallticket.php?hal=08481f0033&ec=2100814&coderep=0");
URLConnection yahooConnection = yahoo.openConnection();
DataInputStream dis = new DataInputStream(yahooConnection.getInputStream());
String inputLine;
String outputLine=null;
while ((inputLine = dis.readLine()) != null) {
//out.println(inputLine);
outputLine=outputLine+inputLine+"\n";
}
out.println(outputLine);
//dis.close();
FileWriter fstream = new FileWriter("c:\\out.txt");
BufferedWriter outx = new BufferedWriter(fstream);
outx.write(outputLine);
outx.close();
dis.close();
}catch (Exception ioe) {
out.println(ioe);
}
%>
--------------------------------------------------------------------------------
so the data is save in the out.txt file as html code
and you have to parse it using txt parser program
For Further reference visit this link below
http://download.oracle.com/javase/tutorial/networking/urls/definition.html
No comments:
Post a Comment