如果网站使用基本身份验证,如何使用 PHP 获取网站源?
<?php
$ch = curl_init("http://domain.com/password.html");
$fp = fopen("source.txt", "w");
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_FILE, $fp);
$output = curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
我究竟做错了什么?