PhpLogLick Posted September 16, 2008 Share Posted September 16, 2008 I want to know how can I get results from google in text file. One search box,where I type what I want then when I got results,script need to record found urls in txt file. Or just print it at current page thanks Link to comment https://forums.phpfreaks.com/topic/124470-how-to-get-results-from-google-in-text-file/ Share on other sites More sharing options...
jamesbrauman Posted September 16, 2008 Share Posted September 16, 2008 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 https://forums.phpfreaks.com/topic/124470-how-to-get-results-from-google-in-text-file/#findComment-642758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.