Outils pour utilisateurs

Outils du site


php:curl

Ceci est une ancienne révision du document !


Fonction cURL téléchargement page web

function get_web_page( $url ) {

  $user_agent='Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0';
  $options = array(
      CURLOPT_CUSTOMREQUEST  =>"GET",
      CURLOPT_USERAGENT      => $user_agent,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HEADER         => false,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_ENCODING       => "",
      CURLOPT_AUTOREFERER    => true,
      CURLOPT_CONNECTTIMEOUT => 10,
      CURLOPT_TIMEOUT        => 10,
      CURLOPT_MAXREDIRS      => 3,
   );
  $ch = curl_init( $url );
  curl_setopt_array( $ch, $options );
  $content = curl_exec( $ch );
  $curlerror  = curl_error( $ch );
  $WebPage  = curl_getinfo( $ch );
  curl_close( $ch );
  $WebPage['curl_error']  = $curlerror;
  $WebPage['content'] = $content;
  return $WebPage;

}

php/curl.1509030946.txt.gz · Dernière modification: 2017-10-26 17:15 de mitsu