Thread: Jhsb no rss
View Single Post
Old 08-15-2011, 10:58 PM   #3
society2008
Junior Member
society2008 began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Mar 2011
Device: kindle k3
original jhsb.recipe:

from calibre.web.feeds.news import BasicNewsRecipe
import re

class jhsb(BasicNewsRecipe):
title = u'jhsb'
__author__ = 'zyl'
language = 'zh'
oldest_article = 7
max_articles_per_feed = 100
no_stylesheets = True
cover_url = 'http://epaper.jinghua.cn/tplimg/logo_080715.gif'
language = 'zh'
keep_only_tags = []
keep_only_tags.append(dict(name = 'div', attrs = {'class': 'new_b_b_b'}))



def parse_index(self):
catnames = {}
catnames["http://epaper.jinghua.cn/html/"] = ""

feeds = []

for cat in catnames.keys():
articles = []
soup = self.index_to_soup(cat)
for a in soup.findAll('a',attrs={'href' : re.compile(cat+"201[0-9]-[0-1][0-9]/[0-1][0-9]/[0-9][0-9][0-9][0-9][0-9][0-9].html")}):
url = a['href'].strip()
myarticle=({'title':self.tag_to_string(a), 'url':url, 'description':'', 'date':''})
self.log("found %s" % url)
articles.append(myarticle)
self.log("Adding URL %s\n" %url)
if articles:
feeds.append((catnames[cat], articles))
return feeds

The web may log on without registration,can rdisplay any news.
society2008 is offline   Reply With Quote