PHP cURL to get Website data

PHP cURL to get Website data

PHP Program:

<?php error_reporting(E_ALL ^ E_NOTICE); ?>
<form method="post" action="compare.php">
<div id="input" style="text-align: center; margin-top: 45px;">
Enter the website to Open :<input type="text" name="pname" id="pname" size="45"/>
</div> 
</form>
<?php
$siteName = $_POST['pname'];
if($siteName){
    $curl_connection = curl_init();
    $url = "$siteName";
    curl_setopt($curl_connection, CURLOPT_URL, $url);
    curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl_connection, CURLOPT_REFERER, "https://www.registrar.usf.edu/");
    $result = curl_exec($curl_connection);
    echo $result;     
}
?>

Output:

php curl 1
php curl 2
php curl 3

Recommended Books:

566 total views, 2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *