Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: google search

  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default google search

    I was wondering how it is possible to highlight a phrase and use some hotkeys for example "ctrl+1" in java to search that phrase by google?


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: google search

    Check out Desktop#browse(URI)

    You will need to build up a suitable URI from the selected phrase in the form that Google expects, something like
    "http://www.google.com/search?q=" + word1 + "+" + word2 ...
    where word1, word2 ... are split from the search phrase.

    You may need to convert special characters into their HTML entities (not sure about that).

    db

  3. #3
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: google search

    thx, but how should I recognize google language.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: google search

    Quote Originally Posted by Darryl.Burke View Post
    You may need to convert special characters into their HTML entities (not sure about that).
    URLEncoder (Java Platform SE 6)

    nasi, you may wish to review google's terms of use to make sure what you want to accomplish doesn't violate it. There are other tiny issues you may have with doing what I think you wish to do, such as parsing/displaying the html output as well as receiving correct output from google (in my experience is wasn't as simple as D.B.'s suggestion - one suggestion: if accessing via a URLConnection make sure you set the user-agent request property, for example to Mozilla)

  5. #5
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: google search

    I have checked their guidelines, I am not going to send lots of queries simultaniously.

  6. #6
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: google search

    Sorry Copeg, but I don't know how to set user-agent request property. I can not find any method regarding it in URLConnection class

  7. #7
    Member
    Join Date
    Mar 2010
    Posts
    111
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: google search

    Thanks Copeg, done.

  8. #8
    Member wolfgar's Avatar
    Join Date
    Oct 2009
    Location
    the middle of the woods
    Posts
    89
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: google search

    in java , i have no idea
    but in a diffrent programming language i know a really
    easy way to do that

    if ur on a windows machine check out autohotkey
    i've used it for all kinds of small things , including
    doing some tedious homework and a little thing
    that types in what i need in the cmd to compile classes
    Programming: the art that fights back

Similar Threads

  1. Breadth First Search Problem
    By Flash8 in forum Algorithms & Recursion
    Replies: 0
    Last Post: March 14th, 2010, 07:27 PM
  2. Binary Search Tree
    By Koren3 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 12th, 2009, 09:27 AM
  3. Arrays.sort or iterative search?
    By igniteflow in forum Collections and Generics
    Replies: 1
    Last Post: September 16th, 2009, 02:07 AM
  4. How to highlight search keyword in text?
    By Mohd in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: February 1st, 2009, 06:35 AM
  5. Implementation of search function for Patricia Trie
    By javaguy in forum What's Wrong With My Code?
    Replies: 0
    Last Post: July 21st, 2008, 01:54 PM

Tags for this Thread