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 7 of 7

Thread: query Google in Java

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Location
    Portsmouth, UK
    Posts
    4
    My Mood
    Sleepy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default query Google in Java

    Hi guys,

    I am not really sure whether this is the right place for my question and forgive me if it is not but I am a newbie.
    I am trying to figure out a way to send a query to Google search engine through my Java application and then get the results and present the links to the user. I am not looking for a code or anything like this. I just need a clue what to use in order to accomplish what I want. I did so much research but I am still confused.
    Any suggestions are welcomed. I will be very thankful if you can give me links to tutorials or other helpful staff.

    If I find anything relevant that I think is interesting, I will contribute to the thread as well as there aren't many up to date ones.


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

    Default Re: query Google in Java

    See Lesson: Working with URLs (The Java™ Tutorials > Custom Networking)

    You should also read google's terms of use...in particular:
    don’t interfere with our Services or try to access them using a method other than the interface and the instructions that we provide

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Location
    Portsmouth, UK
    Posts
    4
    My Mood
    Sleepy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: query Google in Java

    Quote Originally Posted by copeg View Post
    Hi copeg,

    Thanks for your reply.
    I tried that but the thing is that it is showing the HTML code and I want to see the actual links displayed as they are in the browser. Any ideas how I can do that?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: query Google in Java

    Are you asking how to format HTML like a browser does?
    The JEditorPane and JTextPane classes will do some of that.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: query Google in Java

    I want to see the actual links displayed as they are in the browser
    And then what? Why not just show them in a browser by using java.util.ProcessBuilder to run something like "firefox http://google.com/search?q=java"?

  6. #6
    Junior Member
    Join Date
    Apr 2012
    Location
    Portsmouth, UK
    Posts
    4
    My Mood
    Sleepy
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: query Google in Java

    Quote Originally Posted by Sean4u View Post
    And then what? Why not just show them in a browser by using java.util.ProcessBuilder to run something like "firefox http://google.com/search?q=java"?
    It's a good suggestion but I don't want to open it in a browser. What I want is to have like an additional panel to my application that has the first 5 links suggested by Google. At the moment I am trying to use Google Custom Search API but since I have never been working with it I am having trouble using it. There aren't any samples provided or at least I couldn't find any useful. Have you ever used it? Do you have any idea where I can take a look for example codes or something similar??

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

    Default Re: query Google in Java

    Quote Originally Posted by mimka15 View Post
    At the moment I am trying to use Google Custom Search API but since I have never been working with it I am having trouble using it. There aren't any samples provided or at least I couldn't find any useful. Have you ever used it? Do you have any idea where I can take a look for example codes or something similar??
    Then you've probably seen the following: https://developers.google.com/custom.../v1/using_rest
    And as my advice above suggests, use a URL to open up the url for the custom search API link, then parse the results as needed.

Similar Threads

  1. How to Use google Dictionary in my Java APplication
    By jaikumar in forum Web Frameworks
    Replies: 1
    Last Post: January 30th, 2012, 09:56 AM
  2. Simple Google Maps like Image viewer in Java
    By javaguy2020 in forum What's Wrong With My Code?
    Replies: 26
    Last Post: December 7th, 2011, 11:46 PM
  3. update query is firing first then insert query
    By salmondavid88 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 8th, 2011, 10:15 AM
  4. Problem with Java/MySQL query...
    By RiskyShenanigan in forum JDBC & Databases
    Replies: 2
    Last Post: March 28th, 2011, 03:50 AM
  5. JAVA and Google Maps
    By aussiemcgr in forum Java Theory & Questions
    Replies: 7
    Last Post: February 1st, 2011, 08:57 PM