V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
hustlzp
V2EX  ›  分享创造

最近的一个兴趣项目——Blogbar:聚合个人博客( Alpla 版)

  •  
  •   hustlzp ·
    hustlzp · 2014-12-16 10:25:05 +08:00 · 3063 次点击
    这是一个创建于 3427 天前的主题,其中的信息可能已经有所发展或是发生改变。

    http://www.blogbar.cc

    平常挺喜欢写博客,所以这一个多月抽时间做了个博客相关的兴趣项目 Blogbar,用一句话介绍这个产品就是:聚合个人博客

    之前已经在一个帖子中发布了( http://www.v2ex.com/t/147969 ),不过那个时候还是刚刚 Alpha 初期。最近把界面简单地整了一下,修复了一些bug,现在这个版本算是 Alpha 正式版了,基本可用。

    使用简介

    • 推荐博客:你可以向 Blogbar 推荐个人博客(不接受非个人博客、或个人运营的商业博客)
    • 博客广场:给博客打了一些标签,你可以在博客广场浏览各种博客
    • 编辑推荐:每天都会在当天更新的文章中推荐一些到首页(RSS订阅源: http://www.blogbar.cc/feed/posts.xml
    • Wiki:在 http://www.blogbar.cc/wiki 总结了下写博客的各种方式,如果打算写博客,可以看看

    如果有一篇个人博客挺有价值的,但是并不提供 RSS/Atom 订阅,可以写一个 Spider 放到 https://github.com/blogbar/blogbar/tree/master/spiders 下面,在 Spider 中继承 BaseSpider,重写一些属性 & 方法就 OK。比如我想爬王垠的博客(http://www.yinwang.org, 目前已 offline…):

    # coding: utf-8
    import datetime
    from .base import BaseSpider, get_inner_html, remove_element
    
    
    class WangYinSpider(BaseSpider):
        url = 'http://www.yinwang.org'
        title = '当然我在扯淡'
        author = '王垠'
    
        @staticmethod
        def get_posts(tree):
            posts = []
            for item in tree.cssselect('.list-group-item a'):
                title = item.text_content()
                url = item.get('href')
                # 获取日期
                date_list = filter(None, url.split('/'))
                day = int(date_list[-2])
                month = int(date_list[-3])
                year = int(date_list[-4])
                published_at = datetime.datetime(year=year, month=month, day=day)
                posts.append({
                    'title': title,
                    'url': url,
                    'published_at': published_at
                })
            return posts
    
        @staticmethod
        def get_post(tree):
            content_element = tree.cssselect('body')[0]
            remove_element(content_element.cssselect('h2')[0])  # 去除h2标题
            remove_element(content_element.cssselect('p')[0])  # 去除第一个段落
            return get_inner_html(content_element)
    

    使用 lxml 解析 HTML,文档参考: http://lxml.de

    提建议

    欢迎大家提建议!

    可以直接回帖,或者在 http://www.blogbar.cc/suggest 留言,或者在 https://github.com/blogbar/blogbar 上 Pull Request、开 issue,都欢迎。

    Beta 版计划

    • 加入账户系统
    • 每个人可以订阅自己喜欢的博客

    不过最近LZ会有好长一段时间不会开发 Blogbar 了,公司的远程实习开始了,也还有另外一个坑打算和小伙伴一起挖,所以 Blogbar 这边暂停下…

    之前弃了好多坑,但 Blogbar 这个坑就我感觉是可以持续挖下去的。

    BTW,有豆瓣的童鞋在吗?之前我一直在豆瓣九点( http://9.douban.com )找好博客,不过最近挂了好久,没人管了么…

    4 条回复    2014-12-16 13:40:59 +08:00
    lagramoon
        1
    lagramoon  
       2014-12-16 11:04:15 +08:00
    9点好像已沉,修炼?
    hustlzp
        2
    hustlzp  
    OP
       2014-12-16 11:40:01 +08:00
    @lagramoon 挂了接近一周...

    之前豆瓣收购抓虾,估计抓虾的系统都移到9点上面来了。

    9点虽然有很多槽点,不过还是不错的产品。
    invite
        3
    invite  
       2014-12-16 13:38:58 +08:00   ❤️ 1
    不错的,N久之前搞过类似的东东,后来就不更新了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2366 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 07:18 · PVG 15:18 · LAX 00:18 · JFK 03:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.