Jump to content

How to get results from google in text file?


PhpLogLick

Recommended Posts

Well, this is what I would do. (Note, this probably wont work as I am just trying to get across an idea):

$search_string = $_POST['search_string'];
// You need code here for converting the search string found from post into a valid google search url, I
// have no idea how you would do this. Google urls are in this format though:
// http://www.google.com/search?hl=en&q=WORD1+WORD2   etc, although be noted that special
// characters such as " or $ turn into things like '%22d'.
$url = function_for_converting($search_string);
$handle = fopen($url, "r");
if ($handle) {
$contents = stream_get_contents($handle);
fclose($handle);
}
// The code above will return the HTML of the google page. You need to parse this source html for
// the information you need. Google for get_string_between php function, that will get you
// started. I assume you will get each result as an array element
$handle = fopen("googleresults.txt", "w");
if ($handle) {
  foreach ($google_results as $value) {
    fwrite($handle, $value."\r\n");
  }
  fclose($handle);
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.