accessing the results from a Google search!

I'm in the middle of a year project in university, for which I need to access the results from a Google search and write them to a file so that i can work with the results.

I don't want the results to be returned straight back into the program by Google as I need to gain access to them in order to be able to sort them.

I tried various languages including JavaScript, ASP and HTML with no success, would anyone have any suggestions or links to further information?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I did something like what you describe in Delphi 5.0, though I would think it would be possible in ASP.  However, it is pretty east in Delphi 5.0 with the TWebbrowser component

dorward pointed to the link I was going to - Google offers a SOAP interface, so it's easy to access with .Net or Java.
This kind of thing can be quite easy to do in PHP.

the code would look something like this (untested):

    $search = "tennyson"
    $URL = "".$search."&ie=UTF-8&oe=UTF-8";

     $fileHandle = fopen ($URL, "rb");
     $fileData = fread ($fileHandle, filesize ($URL));
     fclose ($fileHandle);

    // google's matches are of a standard HTML structure. The match titles are prepended by <!--m-->, for example.
    // the result data can therefore be extracted using a global regular expression match.

    if (preg_match_all("'<!--m--><a href.*?</a>'si", $fileData, $matches)) {
        // extract the link text and href
        // output these for use

depending on what you want to do, you can customise the regular expression which does the initial search and chop up the resulting matches to suit your needs.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.