HttpWebRequest 是否遵守 .Net 中的 robots.txt?
我正在为 Web 开发人员创建一个工具,它将“扫描”他们网站上的 HTML。
这需要我的 Asp.Net 应用程序从他们的站点下载页面。
为了防止滥用,我想确保我遵守 robots.txt 等方法。
HttpWebRequest 已经这样做了吗?或者是否有一个开源实现可以用来验证给定用户代理字符串的 robots.txt 文件?
I am creating a tool for Web Developers which will 'scan' the HTML on their site.
This requires my Asp.Net application to download a page from their site.
To protect from abuse, I want to make sure I obey robots.txt, among other methods.
Does HttpWebRequest do this already? Or is there an open source implementation I can use to validate a robots.txt file given a user-agent string?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HttpWebRequest
仅发出一个 HTTP 请求。它不遵守robots.txt
,因为它不知道它的存在。需要另一个请求来查看它是否存在并读取其内容,如果默认情况下这样做,您将有 50% 的开销。对于 C# 实现,请查看此处:任何人都有 C# 代码来解析 robots.txt 并根据它评估 URL
HttpWebRequest
just makes one HTTP request. It doesn't obeyrobots.txt
because it doesn't know it exists. It would take another request to see if it exists and read its contents, and if it did that by default you 'd have 50% overhead.For a C# implementation, have a look here: Anybody got any C# code to parse robots.txt and evaluate URLS against it