I am trying to use this code in my
servlet:
public static void main(
String[] args) throws Exception {
URL yahoo = new URL("http://images.google.com/images?q=this");
BufferedReader in = new BufferedReader(new InputStreamReader(yahoo
.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
but it gives this error :
java.io.IOException: Server returned HTTP response code: 403 for URL:
http://images.google.com/images?q=this at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:814)
at java.net.URL.openStream(URL.java:913)
at URLReader.main(URLReader.java:8)
This works for yahoo image search but not for google..
Google image search works with .NET code available at
http://www.codeproject.com/cs/library/google_image_search_api.asp but it doesnt work with
java Please help.