SHARE
TWEET

how to use crawlera

a guest Feb 14th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. //always use
  4. //curl_setopt($ch, CURLOPT_PROXY, "proxy.crawlera.com:8010");
  5. //curl_setopt($ch, CURLOPT_PROXYUSERPWD, "5ce4d6207d9143799c0182d8ce326436:");
  6. //before CURLOPT_URL
  7. /**
  8.  * example:
  9.  * curl_setopt($ch, CURLOPT_URL, "https://google.com");
  10.  * curl_setopt($ch, CURLOPT_PROXY, "proxy.crawlera.com:8010");
  11.  * curl_setopt($ch, CURLOPT_PROXYUSERPWD, "5ce4d6207d9143799c0182d8ce326436:");
  12.  *
  13.  *  CURLOPT_PROXY => server proxy [proxy.crawlera.com:8010]
  14.  *
  15.  *  CURLOPT_PROXYUSERPWD => your user credentials [5ce4d6207d9143799c0182d8ce326436:]
  16.  *
  17.  *  thats all.
  18.  *
  19.  *
  20.  */
  21.  
  22.  
  23.  
  24.  
  25. $ch = curl_init();
  26. curl_setopt($ch, CURLOPT_URL, "https://google.com");
  27. curl_setopt($ch, CURLOPT_PROXY, "proxy.crawlera.com:8010");
  28. curl_setopt($ch, CURLOPT_PROXYUSERPWD, "5ce4d6207d9143799c0182d8ce326436:");
  29. curl_setopt($ch, CURLOPT_HEADER, true);
  30. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  31. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  32. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  33. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  34.  //required for HTTPS
  35. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  36.  //required for HTTPS
  37. $scraped_page = curl_exec($ch);
  38. if($scraped_page === false){    
  39.     echo 'cURL error: ' . curl_error($ch);
  40. }else{    
  41.     echo $scraped_page;
  42. }
  43. curl_close($ch);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top