我是 php 新手,我想通过使用 php curl 获取网页 html...我没有得到输出,只是得到了一个白页。有人可以帮忙吗?
<?php
$url=$_POST['txturl'];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
?>
Run Code Online (Sandbox Code Playgroud)
您不需要两次发送 URL
<?php
$url=$_POST['txturl'];
$ch = curl_init();//I have removed it from here
curl_setopt($ch, CURLOPT_URL,$url);// This will do
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
?>
Run Code Online (Sandbox Code Playgroud)
<?php
echo function_exists('curl_version')?'Yes':'No';
?>
Run Code Online (Sandbox Code Playgroud)