Loading...
terminal
Bymas
RED RU - VPN продажа
KATSTAT.RU-ТОП РЕЙТИНГ САЙТОВ С ОТДАЧЕЙ
ADS LINK - Сервис интернет рекламы
METRO - ПОСТАПОКАЛИПТИЧЕСКАЯ ОНЛАЙН ИГРА
Мобильная 3D онлайн игра Lineage II
WorldByte - Наш хостинг - партнер
PHP/MySQL
| Как в cURL подменить User Agent
Топ дня:
Yamal
Andreukaaa
scam
Автор
28 мая 2015, в 9:09
í ½í²á§Ã¢
подмены переменной User Agent
средствами библиотеки cURL. Для
демонстрации приведены "агенты" ботов
поисковых систем Yandex, Mail.ru, Google,
Bing, Yahoo! и обычный браузер.
<?php
function vzglyanut_kak_robot($url, $bot) {
$user_agents = array(
"Mozilla/5.0 (compatible; YandexBot/3.0;
+http://yandex.com/bots)",
"Mozilla/5.0 (compatible; Mail.RU/2.0)",
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://
http://www.google.com/bot.html)"
;,
"Mozilla/5.0 (compatible; bingbot/2.0; +http://
http://www.bing.com/bingbot.htm)"
;,
"Mozilla/5.0 (compatible; Yahoo! Slurp; http://
help.yahoo.com/help/us/ysearch/slurp)",
"Mozilla/5.0 (Windows NT 6.1; WOW64;
rv:16.0) Gecko/20100101 Firefox/16.0"
);
print "<h1>{$user_agents[$bot]}</h1>";
$kurl = curl_init();
curl_setopt($kurl, CURLOPT_URL, $url);
curl_setopt($kurl,
CURLOPT_RETURNTRANSFER, true);
curl_setopt($kurl, CURLOPT_FAILONERROR,
true);
curl_setopt($kurl, CURLOPT_TIMEOUT, 30);
curl_setopt($kurl, CURLOPT_POST, false);
curl_setopt($kurl,
CURLOPT_FOLLOWLOCATION, true);
curl_setopt($kurl, CURLOPT_USERAGENT,
$user_agents[$bot]);
$stranica = curl_exec($kurl);
return $stranica;
}
$url = "http://h2m.name";
print vzglyanut_kak_robot($url, 0);
?>
DELETED
28 мая 2015, в 9:27
Delete
$br = "Mozilla/5.0 (compatible; YandexBot/3.0;+http://yandex.com/bots)";
function Read($urll)
{
global $br;
$url = "http://ya.ru/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url$urll");
curl_setopt($ch, CURLOPT_COOKIEFILE, $_SERVER['DOCUMENT_ROOT'].'/myferm.txt');
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "$br");
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
curl_close($ch);
// return $result;
}
Форум
На главную