Jump to content

Is it possible to get a website's source code using PHP


kpetsche20

Recommended Posts

For cURL?  It's so ridiculously simple to use for simple web page queries (there's also advanced parts of it, but you don't even need those for this).  Just look at the PHP manual page for curl_init() and you'll probably have all that you need.

US GOOGLE! Jeeze. :/

 

<?php

function file_get_contents_curl($url) {
      $ch = curl_init();

      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_URL, $url);

      $data = curl_exec($ch);
      curl_close($ch);

      return $data;
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.