Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 防止爬虫读取下划线模板_Templates_Web Crawler_Underscore.js_Robots.txt - Fatal编程技术网

Templates 防止爬虫读取下划线模板

Templates 防止爬虫读取下划线模板,templates,web-crawler,underscore.js,robots.txt,Templates,Web Crawler,Underscore.js,Robots.txt,我需要一个robots.txtDisallow规则,防止爬虫跟随模板标记,如标记 爬网时,我获取错误的url如下所示: 404 GET /foo/bar/<%=%20 getPublicUrl %20% 404get/foo/bar/这有点棘手 许多爬虫程序,包括谷歌,在对照robots.txt检查URL之前,会对URL中的任何不安全字符进行静默URL编码。这意味着您必须阻止编码版本 例如,如果URL为: http://example.com/foo/bar/<% my_var %

我需要一个robots.txt
Disallow
规则,防止爬虫跟随模板标记,如
标记

爬网时,我获取错误的url如下所示:

404 GET /foo/bar/<%=%20 getPublicUrl %20%
404get/foo/bar/这有点棘手

许多爬虫程序,包括谷歌,在对照robots.txt检查URL之前,会对URL中的任何不安全字符进行静默URL编码。这意味着您必须阻止编码版本

例如,如果URL为:

http://example.com/foo/bar/<% my_var %>
空格和尖括号是静默URL编码的。所以你需要像这样阻止它:

User-agent: *
Disallow: */%3C%*%%3E
# Does not work:
User-agent: *
Disallow: */<%*%>
如果您试图像这样阻止它:

User-agent: *
Disallow: */%3C%*%%3E
# Does not work:
User-agent: *
Disallow: */<%*%>
#不起作用:
用户代理:*
禁止:*/
然后将不会阻止任何内容,因为它正在将“”与“%3C”和“%3E”进行比较

我已经证实,上述工作为谷歌,但YMMV为其他爬虫。还要注意,一些爬虫程序根本不支持通配符

# Does not work:
User-agent: *
Disallow: */<%*%>