【问题标题】:Block bingbot from crawling my site阻止 bingbot 抓取我的网站
【发布时间】:2015-01-27 02:31:56
【问题描述】:

我现在希望完全阻止 bing 抓取我的网站(它以惊人的速度攻击我的网站(每月 500GB 数据)。

我已将 1000 个子域添加到 bing 网站管理员工具中,因此我无法设置每个子域的抓取速度。 我尝试使用 robots.txt 阻止它,但它不起作用 这是我的 robots.txt

# robots.txt 
User-agent: *
Disallow:
Disallow: *.axd
Disallow: /cgi-bin/
Disallow: /member
Disallow: bingbot
User-agent: ia_archiver
Disallow: /

【问题讨论】:

  • 我还发现 bingbot 在很多我管理的网站上都这样做了。完全忽略一般的“*”规则和任何抓取延迟。

标签: asp.net-mvc .htaccess bots robots.txt bing


【解决方案1】:

这肯定会影响您的 SEO/搜索排名,并会导致页面从索引中下降,因此请谨慎使用

如果您安装了 iis 重写模块,您可以根据用户代理字符串阻止请求(如果没有,请转到 here

然后像这样在你的 webconfig 中添加一个规则:

<system.webServer>
  <rules>
    <rule name="Request Blocking Rule" stopProcessing="true">
      <match url=".*" />
      <conditions>
        <add input="{HTTP_USER_AGENT}" pattern="msnbot|BingBot" />
      </conditions>
      <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this page." />
    </rule>
  </rules>
</system.webServer>

如果机器人访问您的网站,这将返回 403。

更新

查看您的 robots.txt 我认为应该是:

# robots.txt 
User-agent: *
Disallow:
Disallow: *.axd
Disallow: /cgi-bin/
Disallow: /member
User-agent: bingbot
Disallow: /
User-agent: ia_archiver
Disallow: /

【讨论】:

  • 谢谢你,这似乎有效.. 至少来自 bing 网站管理员工具箱验证。
  • 没问题 - 我还在我的答案中添加了我认为您的机器人文件应该是什么(第一个不允许应该是“/”而不是空白。)机器人确实需要时间来获取更改robots.txt 文件,即使您通过网站管理员工具提交。
  • 更新后的机器人将禁止我认为的所有爬虫。现在我正试图阻止 bing 爬行,直到我弄清楚它为什么如此攻击它。
  • web.config 解决方案适用于 Framework 2.0 部署在 IIS 6 Windows 2003 Server 中吗?
【解决方案2】:

您的 robots.txt 不正确:

  • 您需要在记录之间换行(一条记录以一条或多条 User-agent 行开头)。

  • Disallow: bingbot 不允许抓取路径以“bingbot”(即http://example.com/bingbot)开头的 URL,这可能不是您想要的。

  • 不是错误,但不需要Disallow:(因为它是默认设置)。

所以你可能想使用:

User-agent: *
Disallow: *.axd
Disallow: /cgi-bin/
Disallow: /member

User-agent: bingbot
User-agent: ia_archiver
Disallow: /

这将禁止抓取“bingbot”和“ia_archiver”的任何内容。除了路径以 /member/cgi-bin/*.axd 开头的 URL 之外,所有其他机器人都可以抓取所有内容。

请注意,*.axd 将由机器人按照原始 robots.txt 规范进行字面解释(因此它们不会抓取 http://example.com/*.axd,但它们会抓取 http://example.com/foo.axd)。但是,许多机器人扩展了规范并将* 解释为某种通配符。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-28
    • 2015-07-22
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    相关资源
    最近更新 更多