take 10 result from google
can any body help me to complete my program
i want to ask what should put in th startindex and endindex in my code at method (getAddress())
this is my code
import java.io.*;
import java.net.*;
import java.util.*;
public class Google
{
String userRequest, userSearch;
String extract;
Vector S = new Vector();
public Google(String userRequest, Vector Site )
{
userSearch = userRequest;
S = Site;
}
public void SearchRequest()
{
try
{
URL u = new URL("http://www.google.com/search?hl=sq&q="+ userSearch + "&btnG=K%C3%ABrkim+n%C3%AB+Google");
BufferedReader br = new BufferedReader(new InputStreamReader (u.openStream()));
String theHTML;
while((theHTML = br.readLine()) !=null)
{
extract = extract + theHTML;
}
}
catch (MalformedURLException e)
{
System.err.println(" is not a valid URL");
}
catch (NoRouteToHostException e)
{
System.out.println("No result returned");
SearchRequest();
}
catch (SocketException e)
{
System.out.println("No results from searchengine");
SearchRequest();
}
catch (IOException e)
{
System.err.println(e);
}
}
public void getAddress()
{
String Address;
int Addressindex = 0, startindex, endindex;
while ((Addressindex < 10) && ((extract.indexOf("--") >= 0)
&& (extract.indexOf("") >=0)))
{
startindex = (extract.indexOf("")+ 15);
endindex = extract.indexOf("--", startindex);
Address = extract.substring(startindex, endindex);
extract = extract.substring(endindex);
Address = (Address.trim());
Address =("http://" + Address + "/");
S.addElement(Address);
System.out.println(Address);
Addressindex++;
}
}
} // end of class definition

