Kindle:自动追更之Calibre2脚本

 1 #!/usr/bin/env python2
 2 # vim:fileencoding=utf-8
 3 from __future__ import unicode_literals, division, absolute_import, print_function
 4 from calibre.web.feeds.news import BasicNewsRecipe
 5
 6 class rdzs(BasicNewsRecipe):
 7     title          = ‘儒道至圣‘
 8     description = ‘这是一个读书人掌握天地之力的世界。  才气在身,诗可杀敌,词能灭军,文章安天下。  秀才提笔,纸上谈兵;举人杀敌,出口成章;进士一怒,唇枪舌剑。  圣人驾临,口诛笔伐,可诛人,可判天子无道,以一敌国。  此时,圣院把持文位,国君掌官位,十国相争,蛮族虎视,群妖作乱。  此时,无唐诗大兴,无宋词鼎盛,无创新文章,百年无新圣。  一个默默无闻的寒门子弟,被人砸破头后,挟传世诗词,书惊圣文章,踏上至圣之路。‘
 9     max_articles_per_feed = 20000
10     fileName = ‘xx/rdzs.txt‘
11     cover_url  = ‘http://www.50zw.la/files/article/image/2/2806/2806s.jpg‘
12     no_stylesheets = True
13     keep_only_tags = [dict(name=‘div‘, attrs={‘class‘:‘h1title‘}),dict(name=‘div‘, attrs={‘id‘:‘htmlContent‘})]
14     url_prefix = ‘http://www.xxbiquge.com‘
15     no_stylesheets = True
16     keep_only_tags = [dict(name=‘div‘, attrs={‘class‘:‘bookname‘}),dict(name=‘div‘, attrs={‘id‘:‘content‘})]
17     file_object = open(fileName,‘r‘)
18     lastHref = file_object.read()
19     file_object.close()
20     hasLoad = bool(lastHref)
21
22     def get_title(self, link):
23         return link.contents[0].strip()
24
25     def parse_index(self):
26         soup = self.index_to_soup(self.url_prefix+"/5_5690")
27
28         div = soup.find(‘div‘, { ‘id‘: ‘list‘ })
29         lastHref =self.lastHref
30         articles = []
31         for link in div.findAll(‘a‘):
32             til = self.get_title(link)
33             href = link[‘href‘]
34             self.lastHref = href
35             if href == lastHref:
36                 self.hasLoad = False
37             if self.hasLoad:
38                 continue
39             else:
40                 url = self.url_prefix + href
41                 a = { ‘title‘: til, ‘url‘: url }
42                 articles.append(a)
43
44         tutorial = [(self.title, articles)]
45         file_write = open(self.fileName,‘w‘)
46         file_write.write(self.lastHref)
47         file_write.flush()
48         file_write.close()
49         return tutorial

说明:

fileName :是为了简单的记录一下最后一次更新的网址,避免每次都全部更新

上述代码的详细讲解可以看:http://abirdcfly.github.io/2016/03/07/calibre2mobi/
时间: 2024-08-27 17:44:55

Kindle:自动追更之Calibre2脚本的相关文章

linuxshell 实现自动清理rman备份文件的脚本

rman备份脚本 #! /bin/bash su - oracle <<! rman target /<<EOF backup AS COMPRESSED BACKUPSET   database include current controlfile format'/orabak/db_%d_%T_%s' plus archivelog format'/orabak/arch_%d_%T_%s'  delete allinput; delete noprompt obsolete

数据库mysql 自动分库分表备份脚本

数据库mysql 自动分库分表备份脚本 当我们在公司中遇到数据库的备份,项目比较多,经常进行数据库和表的添加工作,那么我们 想要让系统脚本自动进行查询数据库里的库和表结构,然后进行自动的定期进行数据库和表的定期份, 那么我们该如何实现呢,大家看看以下的脚本: vi mysql_backup.sh #!/bin/sh #backup tiandao bbs edoing #coding tonye.li MYUSER=root MYPASS=meidi SOCKET=/data/3306/mysq

Ubuntu自动生成更换壁纸配置文件脚本的困惑

花了一整个下午研究了下Ubuntu怎么自动切换壁纸.其实,感觉还是很简单的,主要就是修改目录/usr/share/backgrouds/contest/trusty.xml的配置文件. 它的格式是这样的: 1 <background> 2 <starttime> 3 <year>2009</year> 4 <month>08</month> 5 <day>04</day> 6 <hour>00<

RHEL自动安装zookeeper的shell脚本

RHEL自动安装zookeeper的shell脚本 A:本脚本运行的机器,Linux RHEL6 B,C,D,...:待安装zookeeper cluster的机器, Linux RHEL6 首先在脚本运行的机器A上确定可以ssh无密码登录到待安装zk的机器B,C,D,...上,然后就可以在A上运行本脚本: $ ./install_zookeeper 前提: B, C, D机器必须配置好repo,本脚本使用的是cdh5的repo, 下面的内容保存到:/etc/yum.repos.d/cloude

Linux自动安装JDK的shell脚本

Linux自动安装JDK的shell脚本 A:本脚本运行的机器,Linux B:待安装JDK的机器, Linux 首先在脚本运行的机器A上确定可以ssh无密码登录到待安装jdk的机器B上,然后就可以在A上运行本脚本: $ ./install-jdk.sh B的IP or: $ ./install-jdk.sh "B的IP" "JDK的URI" 就可以在机器B上安装JDK.jdk使用的tar包需要用户自己设定DEFAULT_JDK_SRC=?,保证可以wget得到即可

Crontab无法自动执行,直接运行脚本却能执行

Crontab无法自动执行,直接运行脚本却能执行 http://bbs.chinaunix.net/thread-1926428-1-1.html crontab -e crontab内容为* * * * * /root/auto.sh /root/auto.sh的内容为#!/bin/bashping -c 1 192.168.0.1 &>/dev/null && result=0 || result=1 if ["$result"==1];then  

一个简单的监控网站是否正常并自动重启服务的shell脚本

#!/bin/sh if [ -z "`curl --connect-timeout 15 --max-time 20 --head --silent http://localhost/index.php|head -n 1|grep '200'`" ];then echo -e "$(date +%Y-%m-%d)\n" killall nginx killall php-fpm /usr/local/nginx/sbin/nginx -c conf/nginx.

豆瓣自动注册、回贴脚本 powered by Python &amp; Selenium

前言,之前在豆瓣日志写了这片文章,结果被豆瓣删除了...哎 ----- 所删除内容 ----- <豆瓣自动注册.回贴脚本 powered by Python & Selenium> (2018-01-12 15:29) 故事起因: 上周的时候吧,发现有条疯狗在这张剧照(天生杀人狂)下面骂我.如果只是骂我傻逼我还能忍,毕竟人在江湖飘哪人不挨刀.但是你问候的范围大了,那作为一个社会主义核心价值观没有问题的青年,我必须得去操一下你妈了吧.请点击操他妈热线.结果这个怂逼居然还发私信骂我然后还把

在MyEclipse的web项目/java项目中,使用Hibernate-tools中的hbm2java和hbm2ddl工具,根据hbm文件自动生成pojo和数据库脚本

     首先,我一定要吐槽下,这个Ant管理部署项目的工具,以及hibernate刚刚学习,导入我这一个简单的问题整了一天多,实在效率有点低下.在这两天中,①了解了Ant,知道了在Ant中很灵活的步骤项目的情况,知道了build.xml文件的一些基本写法.②还学习了在MyEclipse这样的集成工具中完成项目部署.③以及在这两种情况中,利用hibernateTools中的hbm2java和hbm2ddl工具,根据对象关系映射文件,自动生成POJO以及SQL文件(就是数据表). 一,在web项目