You have to log in to edit pages.
Fill the table below with the information required. It is important to write correctly the keywords and the categories, so that your article will be easy to find to the other users. We also recommend to click on watch this page so you will be notified every time another user modifies your tutorial page.
Click on the help buttons close to each field if you need help in filling them.
Java Advanced Java Basics Java EE Java SE Input Output Ajax Algorithms Application Servers Cryptography Databases Hibernate Debugging J2EE Debugging Design Patterns EJB Exceptions GUI Swing Loops Multithreading Networking Reflection Spring SQL Struts WebServices XDoclet XML XSLT XPath Methods Files Generics Servlets Collections Best practices Java5
Category : Java Advanced Java Basics Java EE Java SE Input Output Ajax Algorithms Application Servers Cryptography Databases Hibernate Debugging J2EE Debugging Design Patterns EJB Exceptions GUI Swing Loops Multithreading Networking Reflection Spring SQL Struts WebServices XDoclet XML XSLT XPath Methods Files Generics Servlets Collections Best practices Java5
Free text: {{acknowledgeDerivativeBlock |author= Ganesh Gowtham|link= http://sites.google.com/site/ganeshgowtham}}<br> In this Article we see how can we request the Google to return us the webpages based on our Keyword .<br> In a tradional way we search Google in Browser , Here we see the same via Java Code <br> Infact the best to search the Google is to use google api key [http://code.google.com/apis/ajaxsearch/signup.html Google api]<br> Trick to make appear your name in Google Autocomplete == the code == <source lang="java"> /** * @author Ganesh Gowtham * @url http://sites.google.com/site/ganeshgowtham * Proxy class (HttpAuthenticateProxy) needs to be used * when you are using the internet using the proxy authetication */ class HttpAuthenticateProxy extends Authenticator { String userName = null; String password = null; public HttpAuthenticateProxy(String userName, String password) { this.userName = userName; this.password = password; } protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(userName, password.toCharArray()); } } </source> <source lang="java"> /** * @author Ganesh Gowtham * @url http://sites.google.com/site/ganeshgowtham * Proxy class (HttpAuthenticateProxy) needs to be used * when you are using the internet using the proxy authetication * http.proxyHost- Proxy Server Name * http.proxyPort- Proxy Port Number * proxyuserName - Proxy Server UserName * proxyPwd - Proxy Server Password */ public class GoogleSearchExample { public static void main(String[] args) throws Exception { Authenticator.setDefault(new HttpAuthenticateProxy("proxyuserName", "proxyPwd")); System.setProperty("http.proxyHost", "proxyServer"); System.setProperty("http.proxyPort", "8080"); while (true) { String link = "http://www.google.co.in/search?q=ganesh+gowtham"; URL url = new URL(link); URLConnection urlConnection = url.openConnection(); urlConnection.setRequestProperty( "User-Agent", "Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (Debian-2.0.0.6-0etch1)"); BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); } in.close(); } } } </source> Below code is necessary as without the "User-Agent" Google will return us the java.io.IOException: Server returned HTTP response code: 403 Hence in the below code we try to simulate and request as if we are sending from Browser ( here i used Mozilla ) Above code i used while(true) which means it will go and end-up in infinite loop keeps pinging Google server , So that you can see your name in Google Auto complete in near future . <source lang="java"> urlConnection.setRequestProperty( "User-Agent", "Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (Debian-2.0.0.6-0etch1)"); </source> <br> [[Image:Ganesh_Gowtham_On_Google_WebPage_auto_complete.jpg|500px|thumb|center]] <br> Wait for some time google to cache your name (keyword) and have fun :-) == see also == *[http://sites.google.com/site/ganeshgowtham Ganesh Gowtham's Website]
Please note that all contributions to WikiJava are considered to be released under the GNU Free Documentation License 1.2 (see Project:Copyrights for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here. You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!
Summary:
This is a minor edit Watch this page
Cancel