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

[2061 byte] By [electronic_2010a] at [2007-11-26 19:16:33]
# 1

google blocks request from application !

just try to display the results to see if it works but i'm not sure!! i know that if i do this in a bash terminal:

wget http://www.google.com --> works well

wget http://www.google.com/search?hl=sq&q=java --> doesn't work !

Message was edited by:

supareno

suparenoa at 2007-7-9 21:29:43 > top of Java-index,Java Essentials,Java Programming...