Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEO优化-robots.txt解读 #1

Open
wall-wxk opened this issue May 9, 2018 · 0 comments
Open

SEO优化-robots.txt解读 #1

wall-wxk opened this issue May 9, 2018 · 0 comments

Comments

@wall-wxk
Copy link
Owner

wall-wxk commented May 9, 2018

一、什么是robots.txt

robots.txt 文件由一条或多条规则组成。每条规则可禁止(或允许)特定抓取工具抓取相应网站中的指定文件路径。

通俗一点的说法就是:告诉爬虫,我这个网站,你哪些能�看,哪些不能看的一个协议。

二、为什么要使用robots.txt

搜索引擎(爬虫),访问一个网站,首先要查看当前网站根目录下的robots.txt,然后依据里面的规则,进行网站页面的爬取。
也就是说,robots.txt起到一个基调的作用,也可以说是爬虫爬取当前网站的一个行为准则。

那使用robots.txt的目的,就很明确了。

  • 更好地做定向SEO优化,重点曝光有价值的链接给爬虫
  • 将敏感文件保护起来,避免爬虫爬取收录

三、robots.txt的示例

栗子如下:

User-agent: Googlebot
Disallow: /nogooglebot/

User-agent: *
Allow: /

Sitemap: http://www.wangxiaokai.vip/sitemap.xml

解析:

名为“Googlebot”抓取工具的用户代理不应抓取 http://wangxiaokai.vip/nogooglebot/ 文件夹或任何子目录。
所有其他用户代理均可访问整个网站。(不指定这条规则也无妨,结果是一样的,因为完全访问权限是系统默认的前提。)
网站的站点地图文件位于 http://www.wangxiaokai.vip/sitemap.xml

四、文件规范

1、文件格式和命名

  • 文件格式为标准 ASCII 或 UTF-8
  • 文件必须命名为 robots.txt
  • 只能有 1 个 robots.txt 文件

2、文件�位置

必须位于它所应用到的网站主机的根目录下

3、常用的关键字

  • User-agent 网页抓取工具的名称
  • Disallow 不应抓取的目录或网页
  • Allow 应抓取的目录或网页
  • Sitemap 网站的站点地图的位置

五、百度网盘的应用

百度网盘的资源,到博文��编写时间为止,已经不能用常用的搜索技巧site:pan.baidu.com 搜索关键字的方式,在baidu.com|google.com|biying.com(国际版还可以勉强搜索到)去搜索对应的资源。
禁止的方式,很大程度上是依靠robots.txt,而不是请去喝茶😆。

以下是访问 http://pan.baidu.com/robots.txt 得到的规则:

可以看到,百度网盘封杀了所有资源文件入口。
最狠的是最后一句:

User-agent: *
Disallow: /

我只想说有资源真的可以为所欲为😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant