Saturday, November 19, 2011

Google & Java?

I wanna write a program using JAVA to get the HTML code of the result page by searching with the key word "asdf". But after setting the URL as follow


URL url = new URL("http://www.google.com/search?q=asdf...


and defining the InputStreamReader as follow


InputStreamReader isr=new InputStreamReader(url.openStre...


run it.


It says : Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://www.google.com/search?q=asdf...


why?

Google %26amp; Java?
I suspect google knows when it is being queried by a typical Java program. Look at my code at the link below to do a less generic web page request.





BTW, I tested my solution and it DOES work.
Reply:Why don't you just use Google API to do queries?


Just go to Google Labs, its pretty easy

baby teeth

No comments:

Post a Comment