我尝试了在- Nutch crawler: accept only english pages中建议的解决方案,即向nutch-site.xml添加以下属性
<property>
<name>http.accept.language</name>
<value>en-us,en-gb,en</value>
<description>Value of the "Accept-Language" request header field.
This allows selecting non-English language as default one to retrieve.
It is a useful setting for search engines build for certain national group.
</description>
</property>我仍然得到西班牙的网址。例如- www.google.com/es-us/asdfghjk。
任何修复nutch-site.xml或regex-urlfilters.txt的建议(任何阻止es-us的regex建议也非常感谢)。谢谢
发布于 2021-03-06 15:25:52
属性http.accept.language设置用于HTTP content negotiation的HTTP头"Accept-Language“。在web浏览器中,"Accept- language“根据浏览器配置、操作系统语言或locale填写。但是,URL显式地请求一个西班牙语页面,服务器(google.com)简单地忽略冲突的"Accept-Language“头。
只获取英文内容没有万无一失的解决方案:
/en(?:-[A-Z]{2})?/:无论如何都应该跟随链接(如果源页面不在English)/(?:es|de|fr|...)(?:-[A-Z]{2})?/中:忽略link在这种情况下,爬网只覆盖几个站点:在可能的情况下使用regex URL过滤器,否则在索引或查询索引时按识别的语言进行过滤。
https://stackoverflow.com/questions/66499528
复制相似问题