本页提供关于为计划使用 Browser Run 访问的网站配置 robots.txt 和 sitemap 的一般指导。
可以通过 Cloudflare 附加的自动请求头识别请求:
- User-Agent:每种 Browser Run 方式有不同的默认 User-Agent,可用于编写针对性的
robots.txt规则 cf-brapi-request-id:Quick Actions 请求的唯一标识符Signature-agent:指向 Cloudflare bot 验证密钥
要使用 WAF 规则而非 robots.txt 允许或阻止 Browser Run 流量,请使用自动请求头页面上的 bot 检测 ID。
配置良好的 robots.txt 有助于爬虫了解可以访问网站的哪些部分。
在 robots.txt 中包含 sitemap 引用,以便爬虫发现你的 URL:
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml你可以列出多个 sitemap:
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap.xml
Sitemap: https://example.com/blog-sitemap.xml使用 crawl-delay 控制爬虫请求页面的频率:
User-agent: *
Crawl-delay: 2
Allow: /
Sitemap: https://example.com/sitemap.xml值以秒为单位。crawl-delay 为 2 表示爬虫在请求之间等待两秒。
如果你想阻止 Browser Run(或其他爬虫)访问你的网站,可以配置 robots.txt 以限制访问。
要阻止所有爬虫访问网站上的任何页面:
User-agent: *
Disallow: /这是最严格的配置,会阻止所有合规 bot,而不仅仅是 Browser Run。
[/crawl` 端点](/browser-run/quick-actions/crawl-endpoint/) 使用 User-Agent `CloudflareBrowserRenderingCrawler/1.0` 标识自身。要阻止 /crawl` 端点同时允许所有其他流量(包括其他 Browser Run Quick Actions 端点,它们使用不同的 User-Agent):
User-agent: CloudflareBrowserRenderingCrawler
Disallow: /
User-agent: *
Allow: /要允许 ``/crawl` 端点 访问你的网站但阻止特定部分:
User-agent: CloudflareBrowserRenderingCrawler
Disallow: /admin/
Disallow: /private/
Allow: /
User-agent: *
Allow: /构建 sitemap 结构以帮助爬虫高效处理你的网站:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/important-page</loc>
<lastmod>2025-01-15T00:00:00+00:00</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/other-page</loc>
<lastmod>2025-01-10T00:00:00+00:00</lastmod>
<priority>0.5</priority>
</url>
</urlset>| 属性 | 用途 | 建议 |
|---|---|---|
<loc> |
页面 URL | 必填。使用完整 URL。 |
<lastmod> |
最后修改日期 | 包含此字段以帮助爬虫识别更新的内容。使用 ISO 8601 格式。 |
<priority> |
相对重要性(0.0-1.0) | 为重要页面设置较高值。爬虫将按优先级顺序处理页面。 |
对于具有多个 sitemap 的大型网站,使用 sitemap 索引文件。Browser Run 使用 depth 参数控制爬取多少层嵌套 sitemap:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
...
</urlset>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap-products.xml</loc>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-blog.xml</loc>
</sitemap>
</sitemapindex>Browser Run 定期重新获取 sitemap 以保持内容新鲜。为 sitemap 提供 Last-Modified 或 ETag 响应头,以便爬虫检测 sitemap 自上次获取以来是否已更改。
- 在所有 URL 上包含
<lastmod>以帮助识别哪些页面已更改。使用 ISO 8601 格式(例如2025-01-15T00:00:00+00:00)。 - 对于具有多个 sitemap 的大型网站,使用 sitemap 索引文件。
- 使用
.gz格式压缩大型 sitemap 以减少带宽。 - 每个文件保持 sitemap 在 50 MB 和 50,000 URL 以下(标准 sitemap 限制)。
- 常见问题:Browser Run 会被 Bot Management 检测到吗? — Browser Run 如何与 bot 防护交互以及如何创建 WAF 跳过规则
- 自动请求头 — Browser Run 使用的 User-Agent 字符串和不可配置请求头