Re: getting the search words from a google query
| From: | Shawn McKenzie | Date: | Wed, 19 Aug 2009 15:07:17 +0000 |
| Subject: | Re: getting the search words from a google query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-296970@lists.php.net to get a copy of this message | ||
MURTUZA KUTUB wrote:
> hey,
>
> i am a beginner at php and i need your help.
>
> i have a list of urls visited on a particular day in mysql database.
> using php i find out all the websites that have a google search.
> now i need to strip apart the google query from the entire url.
> i think parse function is used for it but i am not sure how it is used etc.
>
> if possible plz send me a small snippet as an example.
>
> cheers.
>
> -------------------------------------------------
> Bits-Pilani Goa Campus (http://www.bits-goa.ac.in)
>
<?php
$url =
"http://www.google.com/search?q=php&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a";
$url_parts = parse_url($url);
print_r($url_parts);
parse_str($url_parts['query'], $query_vars);
print_r($query_vars);
?>
Array
(
[scheme] => http
[host] => www.google.com
[path] => /search
[query] =>
q=php&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a
)
Array
(
[q] => php
[ie] => utf-8
[oe] => utf-8
[aq] => t
[rls] => com.ubuntu:en-US:unofficial
[client] => firefox-a
)
Normally for Google the 'q' var is the search term, in this case 'php'.
--
Thanks!
-Shawn
http://www.spidean.com