- Автор темы
- #1
PHP:
function bingcontent($key) {
global $_lang;
if (mb_detect_encoding($key) == "UTF-8"):
$key = trim($key);
else:
$key = iconv(mb_detect_encoding($key) , "UTF-8", $key);
$key = trim($key);
endif;
$key = urlencode($key);
//$key = preg_replace(array("/ /","/_/","/-/"), "+", $key);
$newcontent = array();
for ($_i = 0; $_i <= 10; $_i++){
$urlsbing[] = "http://www.bing.com/search?q=" . $key . "&qs=n&form=QBLH&pq=viagra&first=" . $_i . "1&setmkt=" . $_lang . "&setlang=" . $_lang . "&setplang=" . $_lang;
}
$_pattern = "|<\/span><\/div><p>(.*)<\/p><\/div|iU";
$_pattern_content = array(" ...","...","....","..","!.","?.");
$curldatabing = curlMultiRequest($urlsbing);
foreach($curldatabing as $value){
$_response = str_replace("\n", " ", $value);
preg_match_all($_pattern, $_response, $_matches);
if (!empty($_matches)){
$_content = implode(". ", $_matches[1]);
$_content = str_replace($_pattern_content, ". ", $_content);
$newcontent[] = $_content . ". ";
}
}
$newcontent = implode($newcontent);
$newcontent = strip_tags($newcontent);
if (mb_detect_encoding($newcontent) == "UTF-8"):
$newcontent = trim($newcontent);
else:
$newcontent = iconv(mb_detect_encoding($newcontent) , "UTF-8", $newcontent);
$newcontent = trim($newcontent);
endif;
return $newcontent;
}
Запросов много на эту функцию ежесекундно, что можно придумать что б уменьшит нагрузку?