我有一个相当大的音乐网站,有一个大型的艺术家数据库.我一直在注意其他音乐网站抓取我们网站的数据(我在这里和那里输入虚拟艺术家名称然后谷歌搜索它们).
如何防止屏幕抓取?它甚至可能吗?
// remote.php on http://www.example.com/
<?php
function curl_access()
{ /*
some codes here to detect
this script accessed via
curl or direct and returns $r.
(without checking referrer or user agent)
*/
return $r;
}
$curl_access = curl_access();
if ($curl_access)
{ echo 'Accessed via CURL';
} else
{ echo 'Direct access';
}
?>
// some file on a server
<?php
$h = curl_init();
curl_setopt($c, CURLOPT_URL, "http://www.example.com/remote.php");
curl_exec($c); // returns 'Accessed via CURL'
curl_close($c);
?>
Run Code Online (Sandbox Code Playgroud)