Loading...
html
Bym
as
nightlight
BIGsay — платформа для публикации стате
WorldByte - Наш хостинг - партнер
PHP/MySQL
| Как в cURL подменить User Agent
Топ дня:
Лара
Andreukaaa
[!]
Автор
28 мая 2015, в 9:09
Данный пользователь на доске позора
подмены переменной User Agentсредствами библиотеки cURL. Длядемонстрации приведены "агенты" ботовпоисковых систем Yandex, Mail.ru, Google,Bing, Yahoo! и обычный браузер.<?phpfunction 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://www.google.com/bot.html)","Mozilla/5.0 (compatible; bingbot/2.0; +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; }
Форум
На главную