Jus*_*tin 3 perl seo web-crawler dancer web
我正在尝试使用Perl Dancer Web框架提供robots.txt.我认为有一条刚刚返回文本的路径会起作用,但它似乎将它包装在其中html并body标记.我假设这不会被爬虫正确解释为robots.txt文件.
知道如何正确地做到这一点?
以下是我编写路线的方法:
get '/robots.txt' => sub {
return "User-agent: *\nDisallow: /";
};
提前致谢!
ike*_*ami 12
是什么让你认为它被包装在HTML和BODY元素中?
use Dancer;
get '/robots.txt' => sub {
return "User-agent: *\nDisallow: /\n";
};
dance;
Run Code Online (Sandbox Code Playgroud)
输出:
>lwp-request -e http://127.0.0.1:3000/robots.txt
200 OK
Server: Perl Dancer 1.3112
Content-Length: 26
Content-Type: text/html
Client-Date: Mon, 29 Apr 2013 05:05:32 GMT
Client-Peer: 127.0.0.1:3000
Client-Response-Num: 1
X-Powered-By: Perl Dancer 1.3112
User-agent: *
Disallow: /
Run Code Online (Sandbox Code Playgroud)
我打赌你正在使用一个使用渲染器的客户端来查看它,该渲染器会在看到Content-Type标头时添加这些渲染器text/html.将内容类型设置text/plain为更合适,并且在用于查看文件的渲染器中看起来更好.
get '/robots.txt' => sub {
content_type 'text/plain';
return "User-agent: *\nDisallow: /\n";
};
Run Code Online (Sandbox Code Playgroud)
但最终,它不应该产生任何影响.
发送的另一个选择robots.txt是不为它定义路由,而是将实际robots.txt文件放入public/主Dancer应用程序目录下的子目录中.然后,Dancer会自动将其作为常规文件提供,而不会将其传递给路径处理程序,模板等.
| 归档时间: |
|
| 查看次数: |
357 次 |
| 最近记录: |