V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
这是一个专门讨论 idea 的地方。

每个人的时间,资源是有限的,有的时候你或许能够想到很多 idea,但是由于现实的限制,却并不是所有的 idea 都能够成为现实。

那这个时候,不妨可以把那些 idea 分享出来,启发别人。
14ly

想到一个专治 spider 不守规矩的方法

  •  
  •   14ly · Jan 18, 2015 · 4929 views
    This topic created in 4122 days ago, the information mentioned may be changed or developed.

    看到了http://www.v2ex.com/t/162904
    对付这种情况,可以采用的方法是为爬虫建立专用页面,返回垃圾信息。

    但是我才不会做这么损人不利己的事情

    明明可以借助这个特性搭建自己的私人查询库么

    ./robots.txt:
    User-agent: *
    Disallow: /shegongku/

    ./shegongku/index.html:
    //在这里把各种需要查询又不想浪费自己服务器资源的索引
    //建议加密

    使用时

    直接http://www.haosou.com/s?q=site:{yourhost} inurl:shegongku {yourkeyword}

    10 replies    2015-01-20 13:31:05 +08:00
    vibbow
        1
    vibbow  
       Jan 18, 2015
    然后你就被K站了。
    14ly
        2
    14ly  
    OP
       Jan 18, 2015
    @vibbow K就K,反正我的./robots.txt里已经写了不容许访问,这样不守规矩的爬虫K了才好
    vibbow
        3
    vibbow  
       Jan 18, 2015
    @14ly 如果我没记错的话,Disallow了后并不是说蜘蛛就不会爬了
    Google之类的还是会爬的,然后分析外链,只是不会索引其中的内容而已。
    (好像还是会索引Title的)
    vibbow
        4
    vibbow  
       Jan 18, 2015
    However, robots.txt Disallow does not guarantee that a page will not appear in results: Google may still decide, based on external information such as incoming links, that it is relevant. If you wish to explicitly block a page from being indexed, you should instead use the noindex robots meta tag or X-Robots-Tag HTTP header. In this case, you should not disallow the page in robots.txt, because the page must be crawled in order for the tag to be seen and obeyed.
    14ly
        5
    14ly  
    OP
       Jan 18, 2015
    @vibbow 还真是,要添加<META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW">或者X-Robots-Tag HTTP header,想要试验的同学注意了。
    另外我找不到append了,翻了一下自己以前发过的帖子,明明有append
    imn1
        6
    imn1  
       Jan 18, 2015   ❤️ 1
    防君子不妨小人
    如果我本身就不打算遵守什么协议的话,我一定会这样做:
    做个浏览器,用户访问什么 url 都返回服务器(某公司好像就是这样),然后服务器整合信息,用户就是爬虫
    9hills
        7
    9hills  
       Jan 18, 2015 via iPhone
    天真,都会有一个守规矩的爬虫和一个不守规律的专爬disallow的爬虫的,只是后者不展示而已
    honeycomb
        8
    honeycomb  
       Jan 18, 2015
    强制要求登陆?
    设定UA限制?
    jilaoduizhang
        9
    jilaoduizhang  
       Jan 19, 2015
    @14ly 同感 (●'◡'●)
    lfeng
        10
    lfeng  
       Jan 20, 2015
    robots.txt 本身就只是一个君子协定,国产爬虫几乎没有遵守的各种照爬不误,真不想他们爬只能根据UA定向输出内容
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1508 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 16:22 · PVG 00:22 · LAX 09:22 · JFK 12:22
    ♥ Do have faith in what you're doing.