Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Connecting to Google with Java - Help

Options
  • 19-02-2007 3:54pm
    #1
    Registered Users Posts: 98 ✭✭


    Hi, I 'm starting a project where I have to write a java program(s) where by I have to connect to Google, submit a query, modify the results and display results in a browser language (jsp, asp, html etc). The front end will also be a web page of some description.

    Could some one point me in the right direction i.e. a good web site, example code or a even book...I haven't been able to find much useful info yet myself.

    Thanks,
    Bruce Fan.


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Point you in the right direction, in what aspect?


  • Registered Users Posts: 98 ✭✭Bruce Fan


    As in a link to a web site with information on connecting to a search engine using java and returning results....or a link to sample code in that aspect.


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    http://www.cs.usfca.edu/~wolber/SoftwareDev/Distributed/WebServices/Google/googleJavaTutorial.htm

    A simple search in google with the words "Google API in Java" returned that link.


  • Registered Users Posts: 37,485 ✭✭✭✭Khannie


    Bruce Fan; Do you mean by opening up a socket on port 80, issuing a get request, etc?

    Sounds to me like you're looking for java socket programming examples. They should be all over the place. The basics of what you want to do are:

    open a socket to google.ie on port 80,
    write out a GET request (which includes the search)
    receive back HTML into a string buffer of some description,
    alter the retrieved info,
    spit it back out as html.


  • Registered Users Posts: 98 ✭✭Bruce Fan


    Khannie; that's exactly what I want to do. I just can't find any working example to get me started. I'm fairly proficient with Java but I've never used sockets before.


  • Advertisement
  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    There is a java.net.HttpURLConnection class which provides specific functionality for connecting to web servers.

    By all means rewrite a class using Sockets if you want though :p

    As a quick tip: In order to get data back from Google, you'll have to spoof some browser headers or Google will detect you as an attempt to connect programmatically and will disconnect you.


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Find Java Network Programming by Elliott Rusty Harold in your library.


  • Registered Users Posts: 4,003 ✭✭✭rsynnott


    Google has a SOAP web search API; however, not many people used it, and they recently discontinued support and stopped issuing keys. However, if Yahoo would do, they have something similar. This would give the data back in a sensible defined format and so on.


Advertisement