如何使用python从.mobi文件中获取ISBN号 [英] How to get ISBN number from .mobi file with python

查看:500
本文介绍了如何使用python从.mobi文件中获取ISBN号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用python从.mobi书籍中获取ISBN号?

Is there any way of fetching the ISBN number from a .mobi book using python?

也许有一种方法可以直接使用python读取.mobi文件并搜索10个整数(哪个是ISBN号)?如果我用记事本打开mobi文件,我可以找到数字,但是当我尝试读取文件时,会出现编码错误.

Maybe there is a way of reading the .mobi files directely with python and search for 10 ints which is the ISBN number? if I open the mobi file with notepad i can find the number, but when i try to read the file I get a encoding error.

推荐答案

是.

基本上,您只需解析PalmDB 文件格式. ISBN存储在类型为104EXTH标头字段中.

Basically, you just need to parse the PalmDB file format. The ISBN is stored in the EXTH header field of type 104.

我在编写Kindle收藏管理器时,上面链接的Python PalmDB模块还不成熟,所以我最终自己实现了相关部分,请参见

The Python PalmDB module I have linked above was somewhat immature when I wrote my Kindle collections manager, so I ended up implementing the relevant parts myself, see kiehinen source code for details.

如果可以的话,请使用

If it is OK for you to use my code (It has non-contagious MIT License, should not be a problem, right?) you can just do:

>>> from kiehinen.ebook import Book
>>> b = Book("hobbit.mobi")
>>> b.exth['isbn'][0]
'9780618260300'

如果没有,请参见上面链接的代码.

If not, please see the code linked above.

这篇关于如何使用python从.mobi文件中获取ISBN号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆