php - Keyword Extractor for Query Strings -
i've found few keyword extractors query strings, seem outdated (use deprecated code or don't work).
does know of php query string extractor. or how build function takes "host" "amazon.com" , names of multiple query parameters , returns values of parameters?
for instance, http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3daps&field-keywords=a+tale+of+two+cities&x=0&y=0
if provided "amazon.com" , "field-keywords" how can array: ['a','tale','of','two','cities']
?
thanks in advance!!
clarification
jose's answer covers example amazon doesn't seem work other url:
http://www.bing.com/search?q=christmas+around+the+world&form=qblh&qs=pn&sk=hs1pn4&pq=&sp=6&sc=8-0
http://search.yahoo.com/search;_ylt=anqn0c997qr5siycyt.h2ycbvzx4?p=golf&toggle=1&cop=mss&ei=utf-8&fr=yfp-t-701
you (i) write one.
function getvaluefromdomain($urls, $domain, $key) { foreach ($urls $url) { if (preg_match('/https?:\/\/[^\/]*?' . preg_quote($domain) . '\//', $url)) { parse_str(substr($url, strpos($url, '?') + 1), $output); if (isset($output[$key])) { $array = explode(' ', $output[$key]); return $array; } } } return array(); }
just tad of code stolen @jose's answer :)
update: tested, didn't work, fixed, works.
update 2: didn't work after all, tested, fixed, works.
update 3: added support https
Comments
Post a Comment