-
-
Save geekdenz/2496eaaf7c437ba49bc389e75a10b880 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user_agents = array( | |
'Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36', | |
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36', | |
); | |
function get($index) { | |
global $user_agents; | |
$url = 'https://www.bing.com/search?q=site%3Amicrosoft.com&form=QBLH&sp=-1&pq=site%3Amicrosoft.com&sc=8-18&qs=n&sk=&cvid=195A4B0082114AFC9EEF2D7374C94B7D'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
$userAgent = $user_agents[$index]; | |
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
return $output; | |
} | |
for ($i = 0; $i < count($user_agents) * 10; ++$i) { | |
$output = get($i % count($user_agents)); | |
file_put_contents("/tmp/ua_" . $i . ".html", $output); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment