Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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
Web crawler 如何使用robots.txt中的站点地图创建URL白名单?_Web Crawler_Sitemap_Robots.txt_Whitelist - Fatal编程技术网

Web crawler 如何使用robots.txt中的站点地图创建URL白名单?

Web crawler 如何使用robots.txt中的站点地图创建URL白名单?,web-crawler,sitemap,robots.txt,whitelist,Web Crawler,Sitemap,Robots.txt,Whitelist,我正在尝试创建一个供爬虫访问的URL白名单(换句话说,我想要一个爬虫访问的URL列表,并且我希望爬虫只访问那些文件) 我有一个包含白名单上所有URL的网站地图 我应该如何格式化robots.txt 这行吗 User-agent: * Disallow: / Sitemap: sitemap.txt 还是我必须这样做 User-agent: * Disallow: / Allow: whitelist/* Sitemap: sitemap.txt Sitemap和robots.txt没有直接连

我正在尝试创建一个供爬虫访问的URL白名单(换句话说,我想要一个爬虫访问的URL列表,并且我希望爬虫只访问那些文件)

我有一个包含白名单上所有URL的网站地图

我应该如何格式化robots.txt

这行吗

User-agent: *
Disallow: /
Sitemap: sitemap.txt
还是我必须这样做

User-agent: *
Disallow: /
Allow: whitelist/*
Sitemap: sitemap.txt

Sitemap和robots.txt没有直接连接。它们是不同的技术。robots.txt文件仅用于指向站点地图文件。就这些

因此,第一个示例不会给出所需的结果,因为每个页面的爬行都设置为不允许。第二个示例是正确的,您必须将域添加到站点地图url

User-agent: *
Disallow: /
Allow: whitelist/*
Sitemap: http://www.example.com/sitemap.txt

一些专业的爬虫程序有“ignorerobots.txt”选项,例如,就像Slickplan一样。因此,无需格式化“robots.txt”文件。

每个人都应该知道robots.txt的用途。事实上,一些爬虫程序并没有按照这一点运行,这并不意味着你应该停止遵循robots.txt规范