PHP cURL fake browser agent
I found it to be very useful when querying Google search using a php script, without the alternating browser agent Google blocks the querying IP address very quickly.
So here it is: (I know it looks bad with all the lines breaking, just copy and paste)
function fake_user_agent_http_get($address) {
$agents[] = “Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; Media Center PC 5.0)”;
$agents[] = “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”;
$agents[] = “Opera/9.63 (Windows NT 6.0; U; ru) Presto/2.1.1″;
$agents[] = “Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5″;
$agents[] = “Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.18) Gecko/20081203 Firefox/2.0.0.18″;
$agents[] = “Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16″;
$agents[] = “Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1″;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $address);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $agents[rand(0,(count($agents)-1))]);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
http://de.php.net/array_rand
instead of “rand(0,count($agents)-1)”
heh, it seems there’s a function for everything
I have this script, but i’m not sure it is sending Fake Traffic.
I made a script using 2 behaviors.
1. Jquery calls the GET parameter and call the file SendFakeVisitor.php
2. The file SendFakeVisitor.php is a simple Php curl like yours.
that’s it, unfortunely i was able to investigate those data, and i didn’t find any piece of “Fake Traffic” in my Tracker ( ExtremeTracking.com , Google Analytics and Stats ).
Do you have any ideia how to bypass those trackers, and really fake it, the visitor?
Thanks in advance!
-Quik
I assume that something is wrong with your code, if you would use curl correctly then your php script should send fake user agent headers.
doesnt work for me:
Bad Request
Your client has issued a malformed or illegal request.