turtlenote - 用 markdown 和 latex 公式做笔记
下载 60-Second Science 小工具

“一个-韩寒”的 rss 采集

scturtle posted @ 2012年6月13日 16:08 in python , 12335 阅读

作为一名脑残韩粉兼心灵鸡汤爱好者,把腾讯频道刚出的的“一个-韩寒”这个每天一期的微杂志做了个 rss,大概是每天下午3点5个条目,rss 地址为 hanhanone.appspot.com,主要代码在这里。顺便推荐一下跑了有些年头的豆瓣电影口碑榜的 rss,希望这个也能从此幸福快乐的跑下去……

updated at 2012/10/20: “一个-韩寒”ios 版的rss采集:hanhanonehd.appspot.com

feedly: link

国内: onehd.herokuapp.com

updated at 2013/12/13: 方便起见现只维护 onehd.herokuapp.com ,feedly 请点 link

你好。 说:
2012年9月15日 20:10

朋友,从9月11日起,RSS貌似失效了。求修复啊~好人一生平安。

Avatar_small
scturtle 说:
2012年9月16日 16:36

Google Reader 里一直好的啊,可能是由于墙的原因,临时搭了这个 http://one-scturtle.rhcloud.com/ 应该墙内能访问

wswj 说:
2012年11月02日 20:32

博主太厉害了!
最近找app版的rss一直没寻到,没想到你这儿又把这个做好了,真感谢!

请问博主是如何把app里的内容提出来的?

wakaka 说:
2013年4月04日 18:02

最近网页版和移动客户端版同步了..有兴趣转移到网页版上吗? 虽然好像没什么必要。

Avatar_small
scturtle 说:
2013年4月04日 19:39

感谢提醒,内容补上了

hanfen 说:
2013年4月08日 12:01

啊!为什么之前的全成了网页版的了??? APP版的前期内容还没看完呢...:(..

Avatar_small
scturtle 说:
2013年4月08日 13:38

不明白你的意思,是 google reader?

hanfen 说:
2013年4月09日 08:13

嗯 真聪明
我在google reader里订阅了这个rss 一篇一篇的往下看
突然发现不对了 变成之前在官方网站看过的网页版的了
还能让我看到之前的app版吗?:(

Avatar_small
scturtle 说:
2013年4月09日 11:28

呵呵
你看错源了

hanfen 说:
2013年4月09日 13:55

真是这样 太神奇了 :)

我也发现了

thin_z 说:
2013年4月16日 01:29

用zaker 无法订阅吗?

Avatar_small
scturtle 说:
2013年4月16日 10:52

http://onehd.herokuapp.com/ 这个地址国内可访问

thin_z 说:
2013年4月16日 13:05

可以了,谢谢啦

hanyi 说:
2013年6月25日 11:26

feedly里无法添加这个订阅,不识别为rss。即使从google reader里import进去每天也只更新问答。

Avatar_small
scturtle 说:
2013年6月25日 12:40

这个可以 http://cloud.feedly.com/#subscription%2Ffeed%2Fhttp%3A%2F%2Fhanhanonehd.appspot.com%2F

hanyi 说:
2013年6月26日 10:14

多谢楼主

hanyi 说:
2013年7月03日 18:54

这个feed在feedly里条目经常重复更新

Avatar_small
scturtle 说:
2013年7月06日 00:16

一直有这个问题,因为是直接抓的数据转的 rss,可能是我的 rss 的格式有问题,每当原文改动时就会被认成一篇新的,我尽力早解决吧 :)

James Han 说:
2013年12月12日 09:04

楼主,腾讯的 [一个-韩寒] 今天是最后一次更新,以后将转到 wufazhuce.com 这个官方网站更新。十分期待楼主创建 wufazhuce.com 的 RSS feed。

Avatar_small
scturtle 说:
2013年12月13日 01:18

感谢提醒,onehd.herokuapp.com 这个地址应该还可以继续正常更新

司徒嘉胤 说:
2013年12月13日 18:29

楼主你好,我用的是网络上开源的kindleear在gae上自建推送到kindle的服务,用的是python,用了你的rss后系统登录不能,删掉后就行了。 该服务可以自己写采集代码做成杂志,我看了一下你的代码和它格式不兼容,鄙人有个不情之请,如果方便的话能否帮忙写一份为符合该程序格式的采集代码? 以下发两个例子:

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import re
from base import BaseFeedBook

def getBook():
return FolhaDeSaopaulo

class FolhaDeSaopaulo(BaseFeedBook):
title = 'Folha'
description = 'Folha de Sao paulo'
language = 'pt-br'
feed_encoding = "ISO-8859-1"
page_encoding = "ISO-8859-1"
mastheadfile = "mh_folha.gif"
coverfile = 'cv_folha.jpg'
fulltext_by_readability = False
fulltext_by_instapaper = False
host = r'http://www.folha.uol.com.br/'
keep_only_tags = []
remove_tags = []
remove_ids = ['articleBy','ad-180x150-1','editing_controls']
remove_classes = ['adLabel','gallery','mediaIcons','hide','navigation',
'logo sprite','toolbar','breadcrumb']
remove_attrs = []

feeds = [
(u'Em cima da hora', u'http://feeds.folha.uol.com.br/emcimadahora/rss091.xml'),
#(u'Cotidiano', u'http://feeds.folha.uol.com.br/folha/cotidiano/rss091.xml'),
(u'Brasil', u'http://feeds.folha.uol.com.br/folha/brasil/rss091.xml'),
(u'Mundo', u'http://feeds.folha.uol.com.br/mundo/rss091.xml'),
(u'Poder', u'http://feeds.folha.uol.com.br/poder/rss091.xml'),
(u'Mercado', u'http://feeds.folha.uol.com.br/folha/dinheiro/rss091.xml'),
(u'Saber', u'http://feeds.folha.uol.com.br/folha/educacao/rss091.xml'),
(u'Tec', u'http://feeds.folha.uol.com.br/folha/informatica/rss091.xml'),
#(u'Ilustrada', u'http://feeds.folha.uol.com.br/folha/ilustrada/rss091.xml'),
(u'Ambiente', u'http://feeds.folha.uol.com.br/ambiente/rss091.xml'),
#(u'Bichos', u'http://feeds.folha.uol.com.br/bichos/rss091.xml'),
(u'Ciencia', u'http://feeds.folha.uol.com.br/ciencia/rss091.xml'),
#(u'Equilibrio e Saude', u'http://feeds.folha.uol.com.br/equilibrioesaude/rss091.xml'),
(u'Turismo', u'http://feeds.folha.uol.com.br/folha/turismo/rss091.xml'),
(u'Esporte', u'http://feeds.folha.uol.com.br/folha/esporte/rss091.xml'),
]

def preprocess(self, content):
astart = content.find("<h1>") # start of article
if astart > 0:
aend = content.find('<div id="articleEnd">', astart)
if aend > 0:
title = self.FetchTitle(content)
content = content[astart:aend]
content = self.FragToXhtml(content, title, self.page_encoding)
return content

def processtitle(self, title):
pn = re.compile(r'^(Folha de S\.Paulo|F5) - .+? - (.+?) - \d\d/\d\d/\d\d\d\d$', re.I)
mt = pn.match(title)
if mt:
title = mt.group(2)
return title

#!/usr/bin/env python
# -*- coding:utf-8 -*-
from bs4 import BeautifulSoup
from base import BaseFeedBook, URLOpener, string_of_tag

def getBook():
return Economist

class Economist(BaseFeedBook):
title = 'The Economist'
description = 'Global news and current affairs from a European perspective. deliver on Friday.'
language = 'en'
feed_encoding = "utf-8"
page_encoding = "utf-8"
mastheadfile = "mh_economist.gif"
coverfile = "cv_economist.jpg"
deliver_days = ['Friday',]
extra_css = '''
h2 { font-size: small; }
h1 { font-size: medium; }
'''

feeds = [
('Index', 'http://www.economist.com/printedition'),
]

def ParseFeedUrls(self):
""" return list like [(section,title,url,desc),..] """
mainurl = 'http://www.economist.com/printedition'
urls = []
urladded = set()
opener = URLOpener(self.host, timeout=30)
result = opener.open(mainurl)
if result.status_code != 200:
self.log.warn('fetch rss failed:%s'%mainurl)
return []

content = result.content.decode(self.feed_encoding)
soup = BeautifulSoup(content, "lxml")

#GAE��ȡ�������ƶ�����ҳ����PC��ȡ������ҳ��Щ��һ��
for section in soup.find_all('section', attrs={'id':lambda x: x and 'section' in x}):
h4 = section.find('h4')
if h4 is None:
self.log.warn('h4 is empty')
continue
sectitle = string_of_tag(h4).strip()
if not sectitle:
self.log.warn('h4 string is empty')
continue
#self.log.info('Found section: %s' % section_title)
articles = []
subsection = ''
for node in section.find_all('article'):
subsec = node.find('h5')
if subsec is not None:
subsection = string_of_tag(subsec)
prefix = (subsection + ': ') if subsection else ''
a = node.find('a', attrs={"href":True}, recursive=False)
if a is not None:
url = a['href']
if url.startswith(r'/'):
url = 'http://www.economist.com' + url
url += '/print'
title = string_of_tag(a)
if title:
title = prefix + title
#self.log.info('\tFound article:%s' % title)
if url not in urladded:
urls.append((sectitle,title,url,None))
urladded.add(url)
if len(urls) == 0:
self.log.warn('len of urls is zero.')
return urls

Avatar_small
scturtle 说:
2013年12月14日 16:26

看了看这个项目,没什么在本地测试的方法
或者你可以试试 http://www.dogear.cn/feed/109

James Han 说:
2014年2月24日 10:35

http://onehd.herokuapp.com/ 这个地址在 2 月 17 日完成最后一次更新后就没有后续更新了……

Avatar_small
scturtle 说:
2014年2月24日 22:41

感谢提醒,已修复,中间的就不补档了

L 说:
2014年3月08日 02:35

<item>
<title>VOL.517</title>
<link>http://wufazhuce.com/one/vol.517</link>
<description>
<a href="http://pic.yupoo.com/hanapp/Dz1agol3/rk9xC.jpg"><img src="http://pic.yupoo.com/hanapp/Dz1agol3/rk9xC.jpg"></a><br/>你以为挑起生活的担子是勇气,其实去过自己真正想要的生活才更需要勇气。 from 《革命之路》
</description>
<author>我们&绘图/苏小泡</author>
博主好啊,有没办法只订阅每期的以上内容(就是每日一图一言)想要放在Iwidget插件上

Avatar_small
scturtle 说:
2014年3月08日 15:47

http://yisi.us/2013/05/28/id=3291 这里有你要的 rss

L 说:
2014年3月20日 09:20

非常感谢! 已经用上 http://cl.ly/image/0C0O470O3n2V

wink

L 说:
2014年4月01日 23:09

还是喜欢楼主的排版,楼主上面给的链接里的每日一句放到Iwidget上有重复了.....标题出现一次,内容也有...

Avatar_small
scturtle 说:
2014年4月03日 20:10

http://onehd.herokuapp.com/hg

啥啥啥 说:
2015年7月23日 11:53

文章的时间不对,问答的时间是对的。因为需要每天采取,希望能抽空修复

英里 说:
2015年8月31日 22:16

好像又挂了,希望楼主大大修复 TAT

Avatar_small
scturtle 说:
2015年9月01日 21:46

Fixed. 感谢提醒。

Tommy 说:
2016年7月12日 01:22

感谢分享

Kan 说:
2016年12月01日 09:17

好像从2016年11月26日后又挂了……

JJ 说:
2017年6月06日 17:28

大神,截止我发消息时,你珍贵的一个rss源依然是不可访问的状态,望修复,多谢

Meghalaya Board 12th 说:
2022年8月24日 13:02

MBOSE HSSLC Guess Paper 2023 Download, The Meghalaya Board of School Education MBOSE is a state agency of the Government of Meghalaya State. Meghalaya Board 12th Class Question Paper 2023 It is responsible for conducting the Secondary School Leaving Certificate SSLC as well as the Higher Secondary School Leaving Certificate HSSLC Examinations in the state.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter