?
Solved

accessing the results from a Google search!

Posted on 2003-03-03
4
Medium Priority
?
175 Views
Last Modified: 2010-04-09
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?
0
Comment
Question by:Soupy_G
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Expert Comment

by:ARW
ID: 8059445
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

Thanks
ARW
0
 
LVL 2

Expert Comment

by:memerot
ID: 8059620
dorward pointed to the link I was going to - Google offers a SOAP interface, so it's easy to access with .Net or Java.
0
 

Accepted Solution

by:
falmon earned 150 total points
ID: 8063098
This kind of thing can be quite easy to do in PHP.

the code would look something like this (untested):

<?
    $search = "tennyson"
    $URL = "http://www.google.com/search?q=".$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.

F
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question