Posted By

Awilum on 11/06/10


Tagged

curl


Versions (?)

Faking your User Agent with cURL


 / Published in: PHP
 

  1. $userAgent = "Firefox (WindowsXP) - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6";
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
  4. curl_setopt($ch, CURLOPT_URL,$url);
  5. curl_setopt($ch, CURLOPT_FAILONERROR, true);
  6. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  7. curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  8. curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  9. curl_setopt($ch, CURLOPT_VERBOSE, false);
  10. $html= curl_exec($ch);

Report this snippet  

You need to login to post a comment.