我有一个相当大的音乐网站,有一个很大的艺术家数据库。我一直注意到其他音乐网站在窃取我们网站的数据(我在这里和那里输入假艺人的名字,然后进行谷歌搜索)。
如何防止屏幕刮擦?这可能吗?
我有一个相当大的音乐网站,有一个很大的艺术家数据库。我一直注意到其他音乐网站在窃取我们网站的数据(我在这里和那里输入假艺人的名字,然后进行谷歌搜索)。
如何防止屏幕刮擦?这可能吗?
当前回答
你真的没有什么办法可以完全防止这种情况。刮刮者可以伪造他们的用户代理,使用多个IP地址等,并以正常用户的身份出现。你唯一能做的就是让文本在页面加载时不可用——用图像、flash或JavaScript加载。然而,前两个都是糟糕的想法,如果JavaScript没有为一些常规用户启用,最后一个将是可访问性问题。
如果他们对你的网站进行了猛烈的攻击,并且浏览了你所有的页面,你可以做一些速率限制。
不过还是有希望的。刮刮器依赖于您的网站的数据是一致的格式。如果你能随机分配,它可能会打碎他们的刮刀。比如在每次加载时更改页面元素的ID或类名等。但这需要做很多工作,我不确定是否值得。即便如此,只要有足够的投入,他们可能就能解决这个问题。
其他回答
大多数已经说过了,但是你考虑过CloudFlare的保护吗?我的意思是:
其他公司可能也这么做,CloudFlare是我知道的唯一一家。
我很确定这会使他们的工作复杂化。我还曾经因为速率限制而试图废弃一个受CloudFlare保护的网站的数据(我使用了简单的AJAX请求循环),导致IP被自动禁用了4个月。
方法一(小型场地适用): 提供加密/编码的数据。我使用python (urllib, requests, beautifulSoup等)对web进行了Scape,发现许多网站提供加密/编码的数据,这些数据在任何编程语言中都无法解密,因为加密方法不存在。
我在一个PHP网站上通过加密和最小化输出实现了这一点(警告:这对大型网站来说不是一个好主意),响应总是混乱的内容。
最小化PHP输出的例子(如何最小化PHP页面html输出?):
<?php
function sanitize_output($buffer) {
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\</s', // strip whitespaces before tags, except space
'/(\s)+/s' // shorten multiple whitespace sequences
);
$replace = array('>', '<', '\\1');
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
ob_start("sanitize_output");
?>
方法二: 如果你不能阻止他们,那就给他们提供虚假/无用的数据作为回应。
方法三: 阻止常见的抓取用户代理,你会在主要/大型网站上看到这一点,因为你的user - agent不可能用“python3.4”来抓取它们。
方法四: 确保所有的用户标题都是有效的,我有时提供尽可能多的标题,使我的刮板看起来像一个真实的用户,其中一些甚至不是真实或有效的像en-FU:)。 下面是我通常提供的一些头文件的列表。
headers = {
"Requested-URI": "/example",
"Request-Method": "GET",
"Remote-IP-Address": "656.787.909.121",
"Remote-IP-Port": "69696",
"Protocol-version": "HTTP/1.1",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Encoding": "gzip,deflate",
"Accept-Language": "en-FU,en;q=0.8",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"Dnt": "1",
"Host": "http://example.com",
"Referer": "http://example.com",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36"
}
我同意上面的大部分帖子,我想补充的是,你的网站对搜索引擎越友好,它就越容易被抓取。你可以尝试做一些让刮刀器更难的事情,但它也可能影响你的搜索能力……当然,这取决于你想让你的网站在搜索引擎上排名有多好。
好吧,正如所有帖子所说,如果你想让它对搜索引擎友好,那么机器人肯定会刮。
但你仍然可以做一些事情,它可能适用于60% - 70%的抓取机器人。
制作如下所示的检查器脚本。
如果一个特定的IP地址访问非常快,那么在几次访问(5-10次)后,将其IP地址+浏览器信息保存在文件或数据库中。
下一步
(这将是一个后台进程,并一直运行或在几分钟后调度。)制作另一个脚本,继续检查那些可疑的IP地址。
案例1。如果用户代理是一个已知的搜索引擎,如谷歌,Bing, Yahoo(你可以通过Google找到更多关于用户代理的信息)。那么你一定会看到http://www.iplists.com/。这个列表,并尝试匹配模式。如果它看起来像一个假的用户代理,那么要求在下次访问时填写验证码。(你需要多研究一下机器人的IP地址。我知道这是可以实现的,也尝试了IP地址的whois。这是有帮助的。)
例2。没有搜索机器人的用户代理:只需在下次访问时要求填写验证码。
快速解决这个问题的方法是设置一个陷阱。
Make a page that if it's opened a certain amount of times or even opened at all, will collect certain information like the IP and whatnot (you can also consider irregularities or patterns but this page shouldn't have to be opened at all). Make a link to this in your page that is hidden with CSS display:none; or left:-9999px; positon:absolute; try to place it in places that are less unlikely to be ignored like where your content falls under and not your footer as sometimes bots can choose to forget about certain parts of a page. In your robots.txt file set a whole bunch of disallow rules to pages you don't want friendly bots (LOL, like they have happy faces!) to gather information on and set this page as one of them. Now, If a friendly bot comes through it should ignore that page. Right but that still isn't good enough. Make a couple more of these pages or somehow re-route a page to accept differnt names. and then place more disallow rules to these trap pages in your robots.txt file alongside pages you want ignored. Collect the IP of these bots or anyone that enters into these pages, don't ban them but make a function to display noodled text in your content like random numbers, copyright notices, specific text strings, display scary pictures, basically anything to hinder your good content. You can also set links that point to a page which will take forever to load ie. in php you can use the sleep() function. This will fight the crawler back if it has some sort of detection to bypass pages that take way too long to load as some well written bots are set to process X amount of links at a time. If you have made specific text strings/sentences why not go to your favorite search engine and search for them, it might show you where your content is ending up.
无论如何,如果你从战术和创造性的角度思考,这可能是一个很好的起点。最好的办法就是学习机器人是如何工作的。
我还会考虑打乱一些ID或页面元素上的属性显示方式:
<a class="someclass" href="../xyz/abc" rel="nofollow" title="sometitle">
每次都会改变它的形式,因为一些机器人可能会在你的页面或目标元素中寻找特定的模式。
<a title="sometitle" href="../xyz/abc" rel="nofollow" class="someclass">
id="p-12802" > id="p-00392"