{"id":342803,"date":"2022-12-17T15:00:26","date_gmt":"2022-12-17T15:00:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=342803"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2022-12-17T15:00:26","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=342803","title":{"rendered":"<span>\u00ab\u0427\u0442\u0435\u043d\u0438\u0435 \u2014 \u0432\u0441\u0435\u043c\u0443 \u0433\u043e\u043b\u043e\u0432\u0430!\u00bb \u041f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0435 \u043a\u043d\u0438\u0433\u0438 \u0444\u043e\u0440\u043c\u0430\u0442\u0430 .EPUB \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c36\/ab9\/bf7\/c36ab9bf73a3459db02d391db664ac55.jpeg\" width=\"1600\" height=\"711\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c36\/ab9\/bf7\/c36ab9bf73a3459db02d391db664ac55.jpeg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0447\u0442\u043e \u201c\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c\u201d \u0444\u043e\u0440\u043c\u0430\u0442\u0430 EPUB \u0438\u00a0\u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442, \u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u043a\u043e\u0434 \u0432 \u043a\u043d\u0438\u0433\u0435.\u00a0\u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/index.html#\" rel=\"noopener noreferrer nofollow\"><u>Ebook Lib<\/u><\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0437\u043d\u0430\u0435\u043c \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/beautiful-soup-4.readthedocs.io\/en\/latest\/index.html?highlight=attrs#ulSoup\/\" rel=\"noopener noreferrer nofollow\"><u>Beautiful Soup<\/u><\/a>.<\/p>\n<p>\u0417\u0430\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u043d\u044f \u0442\u0435\u043c\u044b \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u041b\u0438\u0431\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434, \u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430 \u043e\u0442\u0440\u0430\u0441\u043b\u0438 \u0442\u0430\u043a\u0430\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0435\u0441\u043b\u0438 \u0437\u0430\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u0440\u044b \u043a\u043d\u0438\u0433 \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u043d\u0430 2-3 \u0433\u043e\u0434\u0430, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u043a\u043d\u0438\u0433\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043c\u0435\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u043d\u0430\u0434 \u0447\u0435\u043c \u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0441\u0435\u0440\u0434\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0447\u0438\u0442\u0430\u044f \u043c\u043e\u043d\u0443\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0443 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430, \u0432\u0441\u0435 \u0435\u0449\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u043c \u043e\u043a\u043d\u0435 \u0438 \u0441\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u0442\u044b \u0443\u043b\u043e\u0432\u0438\u043b \u043c\u044b\u0441\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430? \u0417\u0430\u043a\u0438\u043d\u0443\u043b PDF \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0435, \u0430 \u0442\u043e \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0438 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u044e\u0442 \u043a\u043e\u0434 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0422\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438 \u0441\u043f\u043e\u0434\u0432\u0438\u0433\u043b\u0430 \u043c\u0435\u043d\u044f \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0410 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Python.<\/p>\n<h3>\u0427\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/py-googletrans.readthedocs.io\/en\/latest\/\" rel=\"noopener noreferrer nofollow\"><u>Googletrans<\/u><\/a> \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">def translation_func(text):\u00a0\u00a0\u00a0     translator = Translator()\u00a0\u00a0\u00a0     result = translator.translate(text, dest='ru')\u00a0\u00a0\u00a0     return result.text<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043c\u00a0\u043a \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0438\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0445 \u043a\u043d\u0438\u0433 &#8212; EPUB. \u0412\u0441\u0435 \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e PDF \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0442\u0435\u043a\u0441\u0442\u0430. \u0410 \u0432\u043e\u0442 EPUB \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0430\u0431\u043e\u0440 XHTML- \u0438\u043b\u0438 HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e \u043d\u0443\u0436\u043d\u044b\u043c \u043d\u0430\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c.\u00a0<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 <a href=\"https:\/\/sigil-ebook.com\/\" rel=\"noopener noreferrer nofollow\"><u>Sigil &#8212; EPUB Editor<\/u><\/a>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c86\/fd3\/741\/c86fd37418418dc28758cccb4d72b5d7.png\" width=\"1600\" height=\"836\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c86\/fd3\/741\/c86fd37418418dc28758cccb4d72b5d7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u0435\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u044b (XHTML, HTML \u0438\u043b\u0438 PDF), \u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0432 \u043a\u0430\u043a\u0438\u0445 \u0442\u0435\u0433\u0430\u0445 \u0443 \u043d\u0430\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043a\u043e\u0434 \u0438 \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430.<\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u0438\u0445 \u0442\u0435\u0433\u043e\u0432:<\/p>\n<pre><code class=\"python\">tag_exeption = ['code', 'a', 'strong', 'pre', 'span', 'html',\u00a0'div', 'body', 'head']<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/index.html#\" rel=\"noopener noreferrer nofollow\"><u>Ebook Lib<\/u><\/a>, \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/aerkalov\/ebooklib\/tree\/master\/samples#ebooklib-samples\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.read_epub\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.read_epub()<\/strong><\/a> \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430\u00a0 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.EpubBook\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.EpubBook<\/strong><\/a>.<\/p>\n<pre><code class=\"python\">from ebooklib import epub  book = epub.read_epub('book.epub')<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0435 (\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0442\u0438\u043b\u0435\u0439, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0432\u0438\u0434\u0435\u043e, \u0437\u0432\u0443\u043a\u0438, \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 HTML-\u0444\u0430\u0439\u043b\u044b) \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e \u0442\u0438\u043f\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.EpubBook.get_items_of_type\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.EpubBook.get_items_of_type()<\/strong><\/a>.<\/p>\n<p>\u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><code>ITEM_UNKNOWN = 0<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_IMAGE = 1<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_STYLE = 2<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_SCRIPT = 3<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_NAVIGATION = 4<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_VECTOR = 5<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_FONT = 6<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_VIDEO = 7<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_AUDIO = 8<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_DOCUMENT = 9<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_COVER = 10<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c<strong> book.get_items() <\/strong>\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0430\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043a\u043d\u0438\u0433\u0438 &#8212; \u043e\u0431\u044a\u0435\u043a\u0442\u044b <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.EpubItem\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.EpubItem<\/strong><\/a>. \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 ITEM_NAVIGATION = 4 \u0438 \u0433\u043b\u0430\u0432\u044b \u043a\u043d\u0438\u0433\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445\u00a0 ITEM_DOCUMENT = 9, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e \u0442\u0438\u043f\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434<strong> item.get_type()<\/strong>.<\/p>\n<pre><code class=\"python\">for item in book.get_items():     if item.get_type() == 4:     \u2026     if item.get_type() == 9:     \u2026<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <strong>item.get_name()<\/strong>, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<strong> item.get_id()<\/strong> \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435<strong> item.get_content().<\/strong><\/p>\n<pre><code class=\"python\">for item in book.get_items():     if item.get_type() == ebooklib.ITEM_DOCUMENT:         print('==================================')         print('NAME : ', item.get_name())\u00a0\u00a0         print('----------------------------------')\u00a0\u00a0         print('ID : ', item.get_id())\u00a0\u00a0\u00a0\u00a0         print('----------------------------------')\u00a0\u00a0\u00a0         print(item.get_content())\u00a0\u00a0\u00a0\u00a0         print('==================================')<\/code><\/pre>\n<pre><code>... ================================== NAME :  Text\/Chapter_6.xhtml ---------------------------------- ID :  Chapter_6 ---------------------------------- b'&lt;?xml version=\"1.0\" encoding=\"utf-8\"?>\\r\\n&lt;ncx version=\"2005-1\" xmlns=\"http:\/\/www.daisy.org\/z3986\/2005\/ncx\/\">\\r\\n&lt;head>\\r\\n ================================== ...<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 XHTML, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0443\u0445 \u043e\u0442 \u043a\u043e\u0442\u043b\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<u> <\/u><a href=\"https:\/\/beautiful-soup-4.readthedocs.io\/en\/latest\/index.html?highlight=attrs#ulSoup\/\" rel=\"noopener noreferrer nofollow\"><u>Beautiful Soup<\/u><\/a>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 soup:<\/p>\n<pre><code class=\"python\">soup = BeautifulSoup(item.get_content(), features=\"xml\")<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442<strong> .descendants.<\/strong> \u041e\u043d \u0445\u043e\u0440\u043e\u0448 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<strong> .contents <\/strong>\u0438<strong> .children <\/strong>\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u044f\u043c\u044b\u0445 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u044f\u043c\u044b\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0427\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u00a0\u0442\u0430\u043a\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b: <strong>.name <\/strong>&#8212; \u0438\u043c\u044f \u0442\u0435\u0433\u0430, <strong>.attrs<\/strong> &#8212; \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0442\u0435\u0433\u0430 (class, id) \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f.<\/p>\n<pre><code class=\"python\">for child in soup.descendants: \u00a0\u00a0\u00a0if child.name and child.string: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(child.name, '->', child.attrs)<\/code><\/pre>\n<pre><code>*** h1 -> {'class': 'chapterNumber'} h1 -> {'class': 'chapterTitle', 'id': '_idParaDest-65'} p -> {'class': 'normal'} li -> {'class': 'bulletList'} a -> {'href': 'https:\/\/github.com\/example\/tree\/main\/Chapter02'} ***<\/code><\/pre>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442 .<strong>descendants<\/strong> \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 soup, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0433\u043e\u0432 \u0438 \u043f\u0443\u0441\u0442\u044b\u0435 \u0442\u0435\u0433\u0438. \u0427\u0435\u0440\u0435\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u0442\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f <strong>tag_exeption<\/strong>, \u0433\u043e\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 (<strong>child.name<\/strong>) \u0438 \u0442\u0435\u0433\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0442\u0435\u043a\u0441\u0442<strong> <\/strong>(<strong>child.string<\/strong>). \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <strong>.string<\/strong> \u0442\u0435\u043a\u0441\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439<strong> translation_func()<\/strong>\u00a0\u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430\u0448\u0435\u043c\u0443 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0442\u0435\u043c \u0436\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <strong>.string<\/strong> .<\/p>\n<pre><code class=\"python\">for child in soup.descendants:     if child.name not in tag_exeption and child.name and child.string:     child.string = translation_func(child.string)<\/code><\/pre>\n<p>\u0422\u0435\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0430 \u043f\u0440\u044f\u043c\u0443\u044e \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <strong>.contents<\/strong>, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u043c\u0435\u043d\u0430 \u0442\u0435\u0433\u043e\u0432 (<strong>not content.name<\/strong>), \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044b <strong>[&#8216;\\n&#8217;, &#8216; &#8216;].\u00a0<\/strong><\/p>\n<pre><code class=\"python\">elif not child.name in tag_exeption and child.name: #and count &lt; 10: \u00a0\u00a0\u00a0 for content in child.contents:         new_contents = [] \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if content.string and content.string not in ['\\n', ' '] and not content.name: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0    translation_text = translation_func(content.string) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 content = NavigableString(translation_text)     \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 new_contents.append(content)      \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new_contents.append(\" \") \u00a0\u00a0 \u00a0child.clear() \u00a0\u00a0\u00a0 child.extend(new_contents)<\/code><\/pre>\n<p>Beautiful Soup \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0435\u043a\u0441\u0442\u0430 \u043a\u043b\u0430\u0441\u0441 <strong>NavigableString, <\/strong>\u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<strong> <\/strong>\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430<strong>, <\/strong>\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0430 <strong>child.clear()<\/strong>,\u00a0\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u043e\u0442\u043e\u043c\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>child.extend(new_contents).<\/strong><\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 book \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0432\u0438\u0434\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 soup, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434<strong> .set_content()<\/strong>, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c.\u00a0<\/p>\n<pre><code class=\"python\">item.set_content(soup.encode())<\/code><\/pre>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 book \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <strong>.open_in_browser(contents)<\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 lxml, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0<a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/index.html#\" rel=\"noopener noreferrer nofollow\"><u>Ebook Lib<\/u><\/a> &#8212; <strong>utils.parse_string(item.get_content()).<\/strong><\/p>\n<p>\u00a0<\/p>\n<pre><code class=\"python\">from ebooklib import epub, utils \u2026 contents = utils.parse_string(item.get_content()) html.open_in_browser(contents)<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e &#8212; \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u0443\u044e \u043a\u043d\u0438\u0433\u0443.<\/p>\n<pre><code class=\"python\">epub.write_epub('new_book.epub', book, {})<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412\u0435\u0441\u044c \u043a\u043e\u0434\u00a0 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from googletrans import Translator from ebooklib import epub, utils from bs4 import BeautifulSoup, NavigableString import lxml.html as html  def open_epub():     tag_exeption = [\"code\", 'a', 'strong', 'pre', 'span', 'html',                     'div', 'body', \"head\"]     book = epub.read_epub('Django 4 By Example 2022.epub')     for item in book.get_items():         if item.get_id() == \"Chapter_7\":             print('NAME : ', item.get_name())             print('----------------------------------')             print('ID : ', item.get_id())             print('----------------------------------')             print('ITEM : ', item.get_type())              soup = BeautifulSoup(item.get_content(), features=\"xml\")              for child in soup.descendants:                 if child.name not in tag_exeption and child.name and child.string:                     tag_text_before = child.string                     translation_text = translation_func(tag_text_before)                     child.string = translation_text                 elif not child.name in tag_exeption and child.name:                     new_contents = []                     class_attr = child.attrs.get('class')                     for content in child.contents:                         if content.string and content.string not in ['\\n', ' '] and not content.name:                             content = NavigableString(translation_func(content.string))                             new_contents.append(content)                             new_contents.append(\" \")                     child.clear()                     child.extend(new_contents)             item.set_content(soup.encode())             contents = utils.parse_string(item.get_content())             html.open_in_browser(contents)             print('==================================')     epub.write_epub('new_book.epub', book, {})  def translation_func(text):     translator = Translator()     result = translator.translate(text, dest='ru')     return result.text  def main():     open_epub()  if __name__ == \"__main__\":     main()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c\u00a0\u043f\u0440\u043e \u0444\u0430\u0439\u043b\u044b CSS, \u0432 \u043a\u043d\u0438\u0433\u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u0442\u0438\u043f\u0430 ITEM_STYLE = 2 \u0438\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 <a href=\"https:\/\/sigil-ebook.com\/\" rel=\"noopener noreferrer nofollow\"><u>Sigil &#8212; EPUB Editor<\/u><\/a> \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043d\u0438\u0433\u0438,<\/p>\n<p>\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043e\u043d\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435 Styles.<\/p>\n<pre><code class=\"xml\">&lt;head> \u00a0\u00a0&lt;title>Example book&lt;\/title> \u00a0\u00a0&lt;link href=\"..\/Styles\/epub.css\" rel=\"stylesheet\" type=\"text\/css\"\/> \u00a0\u00a0&lt;link href=\"..\/Styles\/syntax-highlighting.css\" rel=\"stylesheet\" type=\"text\/css\"\/> &lt;\/head><\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043d\u0438\u0433\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 CSS \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <a href=\"https:\/\/sigil-ebook.com\/\" rel=\"noopener noreferrer nofollow\"><u>Sigil &#8212; EPUB Editor<\/u><\/a>, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043a\u043d\u0438\u0433\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435 text \u0438 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u043c \u043c\u0435\u043d\u044e \u0432\u044b\u0431\u0440\u0430\u0442\u044c &#171;\u0421\u0432\u044f\u0437\u0430\u0442\u044c \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0441\u0442\u0438\u043b\u0435\u0439\u2026\u201d.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0441\u0435! \u041d\u0430\u0448\u0430 \u043a\u043d\u0438\u0433\u0430 \u0433\u043e\u0442\u043e\u0432\u0430!<\/p>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b &#8212; \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043e\u0431\u0449\u0443\u044e \u044d\u0440\u0443\u0434\u0438\u0446\u0438\u044e, \u0443\u0447\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438, \u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043b\u0435\u0437\u0442\u044c \u043f\u043e\u0434 \u201c\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u201d, \u0434\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0440\u0443\u0442\u0438\u043d\u0443.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/706118\/\"> https:\/\/habr.com\/ru\/post\/706118\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0447\u0442\u043e \u201c\u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c\u201d \u0444\u043e\u0440\u043c\u0430\u0442\u0430 EPUB \u0438\u00a0\u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442, \u043d\u043e \u043d\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u043a\u043e\u0434 \u0432 \u043a\u043d\u0438\u0433\u0435.\u00a0\u041f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/index.html#\" rel=\"noopener noreferrer nofollow\"><u>Ebook Lib<\/u><\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u0437\u043d\u0430\u0435\u043c \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 <a href=\"https:\/\/beautiful-soup-4.readthedocs.io\/en\/latest\/index.html?highlight=attrs#ulSoup\/\" rel=\"noopener noreferrer nofollow\"><u>Beautiful Soup<\/u><\/a>.<\/p>\n<p>\u0417\u0430\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430, \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u044b \u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u043d\u044f \u0442\u0435\u043c\u044b \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435. \u041b\u0438\u0431\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434, \u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430 \u043e\u0442\u0440\u0430\u0441\u043b\u0438 \u0442\u0430\u043a\u0430\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0435\u0441\u043b\u0438 \u0437\u0430\u0433\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u0440\u044b \u043a\u043d\u0438\u0433 \u0438\u0441\u043f\u0440\u0430\u0432\u043d\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u0442\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043e\u0442\u0441\u0442\u0430\u0435\u0442 \u043d\u0430 2-3 \u0433\u043e\u0434\u0430, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u043a\u043d\u0438\u0433\u0438 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043c\u0435\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435, \u043d\u0430\u0434 \u0447\u0435\u043c \u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0441\u0435\u0440\u0434\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0447\u0438\u0442\u0430\u044f \u043c\u043e\u043d\u0443\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u043b\u0438\u0442\u0435\u0440\u0430\u0442\u0443\u0440\u0443 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430, \u0432\u0441\u0435 \u0435\u0449\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0432 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u043c \u043e\u043a\u043d\u0435 \u0438 \u0441\u0432\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043b\u0438 \u0442\u044b \u0443\u043b\u043e\u0432\u0438\u043b \u043c\u044b\u0441\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0430.<\/p>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432 \u0447\u0435\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430? \u0417\u0430\u043a\u0438\u043d\u0443\u043b PDF \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0435, \u0430 \u0442\u043e \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0438 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0435 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u044e\u0442 \u043a\u043e\u0434 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435. \u0422\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438 \u0441\u043f\u043e\u0434\u0432\u0438\u0433\u043b\u0430 \u043c\u0435\u043d\u044f \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u0410 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u044f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Python.<\/p>\n<h3>\u0427\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 <a href=\"https:\/\/py-googletrans.readthedocs.io\/en\/latest\/\" rel=\"noopener noreferrer nofollow\"><u>Googletrans<\/u><\/a> \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<pre><code class=\"python\">def translation_func(text):\u00a0\u00a0\u00a0     translator = Translator()\u00a0\u00a0\u00a0     result = translator.translate(text, dest='ru')\u00a0\u00a0\u00a0     return result.text<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043c\u044b \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043c\u00a0\u043a \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0438\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0445 \u043a\u043d\u0438\u0433 &#8212; EPUB. \u0412\u0441\u0435 \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e PDF \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0442\u0435\u043a\u0441\u0442\u0430. \u0410 \u0432\u043e\u0442 EPUB \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u043d\u0430\u0431\u043e\u0440 XHTML- \u0438\u043b\u0438 HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e \u043d\u0443\u0436\u043d\u044b\u043c \u043d\u0430\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c.\u00a0<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 \u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043e\u0439 <a href=\"https:\/\/sigil-ebook.com\/\" rel=\"noopener noreferrer nofollow\"><u>Sigil &#8212; EPUB Editor<\/u><\/a>.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 \u043a\u0430\u043a\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442, \u0435\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u044b (XHTML, HTML \u0438\u043b\u0438 PDF), \u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0432 \u043a\u0430\u043a\u0438\u0445 \u0442\u0435\u0433\u0430\u0445 \u0443 \u043d\u0430\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043a\u043e\u0434 \u0438 \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430\u043c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430.<\/p>\n<p>\u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u0438\u0445 \u0442\u0435\u0433\u043e\u0432:<\/p>\n<pre><code class=\"python\">tag_exeption = ['code', 'a', 'strong', 'pre', 'span', 'html',\u00a0'div', 'body', 'head']<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/index.html#\" rel=\"noopener noreferrer nofollow\"><u>Ebook Lib<\/u><\/a>, \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/aerkalov\/ebooklib\/tree\/master\/samples#ebooklib-samples\" rel=\"noopener noreferrer nofollow\"><u>\u0437\u0434\u0435\u0441\u044c<\/u><\/a>.<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.read_epub\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.read_epub()<\/strong><\/a> \u0447\u0438\u0442\u0430\u0435\u043c \u0444\u0430\u0439\u043b \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430\u00a0 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.EpubBook\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.EpubBook<\/strong><\/a>.<\/p>\n<pre><code class=\"python\">from ebooklib import epub  book = epub.read_epub('book.epub')<\/code><\/pre>\n<p>\u0412\u0441\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0435 (\u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u0442\u0438\u043b\u0435\u0439, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0432\u0438\u0434\u0435\u043e, \u0437\u0432\u0443\u043a\u0438, \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0438 HTML-\u0444\u0430\u0439\u043b\u044b) \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438. \u0418\u0445 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e \u0442\u0438\u043f\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.EpubBook.get_items_of_type\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.EpubBook.get_items_of_type()<\/strong><\/a>.<\/p>\n<p>\u0412\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><code>ITEM_UNKNOWN = 0<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_IMAGE = 1<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_STYLE = 2<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_SCRIPT = 3<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_NAVIGATION = 4<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_VECTOR = 5<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_FONT = 6<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_VIDEO = 7<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_AUDIO = 8<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_DOCUMENT = 9<\/code><\/p>\n<\/li>\n<li>\n<p><code>ITEM_COVER = 10<\/code><\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c<strong> book.get_items() <\/strong>\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043d\u0430\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043a\u043d\u0438\u0433\u0438 &#8212; \u043e\u0431\u044a\u0435\u043a\u0442\u044b <a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/ebooklib.html#ebooklib.epub.EpubItem\" rel=\"noopener noreferrer nofollow\"><strong>ebooklib.epub.EpubItem<\/strong><\/a>. \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 ITEM_NAVIGATION = 4 \u0438 \u0433\u043b\u0430\u0432\u044b \u043a\u043d\u0438\u0433\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u0432 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445\u00a0 ITEM_DOCUMENT = 9, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e \u0442\u0438\u043f\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434<strong> item.get_type()<\/strong>.<\/p>\n<pre><code class=\"python\">for item in book.get_items():     if item.get_type() == 4:     \u2026     if item.get_type() == 9:     \u2026<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 <strong>item.get_name()<\/strong>, \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430<strong> item.get_id()<\/strong> \u0438 \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435<strong> item.get_content().<\/strong><\/p>\n<pre><code class=\"python\">for item in book.get_items():     if item.get_type() == ebooklib.ITEM_DOCUMENT:         print('==================================')         print('NAME : ', item.get_name())\u00a0\u00a0         print('----------------------------------')\u00a0\u00a0         print('ID : ', item.get_id())\u00a0\u00a0\u00a0\u00a0         print('----------------------------------')\u00a0\u00a0\u00a0         print(item.get_content())\u00a0\u00a0\u00a0\u00a0         print('==================================')<\/code><\/pre>\n<pre><code>... ================================== NAME :  Text\/Chapter_6.xhtml ---------------------------------- ID :  Chapter_6 ---------------------------------- b'&lt;?xml version=\"1.0\" encoding=\"utf-8\"?>\\r\\n&lt;ncx version=\"2005-1\" xmlns=\"http:\/\/www.daisy.org\/z3986\/2005\/ncx\/\">\\r\\n&lt;head>\\r\\n ================================== ...<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 XHTML, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u0442\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0443\u0445 \u043e\u0442 \u043a\u043e\u0442\u043b\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<u> <\/u><a href=\"https:\/\/beautiful-soup-4.readthedocs.io\/en\/latest\/index.html?highlight=attrs#ulSoup\/\" rel=\"noopener noreferrer nofollow\"><u>Beautiful Soup<\/u><\/a>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 soup:<\/p>\n<pre><code class=\"python\">soup = BeautifulSoup(item.get_content(), features=\"xml\")<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442<strong> .descendants.<\/strong> \u041e\u043d \u0445\u043e\u0440\u043e\u0448 \u0442\u0435\u043c, \u0447\u0442\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<strong> .contents <\/strong>\u0438<strong> .children <\/strong>\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u044f\u043c\u044b\u0445 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u044f\u043c\u044b\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0427\u0442\u043e \u0438\u0437 \u0441\u0435\u0431\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u00a0\u0442\u0430\u043a\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b: <strong>.name <\/strong>&#8212; \u0438\u043c\u044f \u0442\u0435\u0433\u0430, <strong>.attrs<\/strong> &#8212; \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0442\u0435\u0433\u0430 (class, id) \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0441\u043b\u043e\u0432\u0430\u0440\u044f.<\/p>\n<pre><code class=\"python\">for child in soup.descendants: \u00a0\u00a0\u00a0if child.name and child.string: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(child.name, '->', child.attrs)<\/code><\/pre>\n<pre><code>*** h1 -> {'class': 'chapterNumber'} h1 -> {'class': 'chapterTitle', 'id': '_idParaDest-65'} p -> {'class': 'normal'} li -> {'class': 'bulletList'} a -> {'href': 'https:\/\/github.com\/example\/tree\/main\/Chapter02'} ***<\/code><\/pre>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442 .<strong>descendants<\/strong> \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 soup, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0433\u043e\u0432 \u0438 \u043f\u0443\u0441\u0442\u044b\u0435 \u0442\u0435\u0433\u0438. \u0427\u0435\u0440\u0435\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u0442\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f <strong>tag_exeption<\/strong>, \u0433\u043e\u043b\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 (<strong>child.name<\/strong>) \u0438 \u0442\u0435\u0433\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0442\u0435\u043a\u0441\u0442<strong> <\/strong>(<strong>child.string<\/strong>). \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <strong>.string<\/strong> \u0442\u0435\u043a\u0441\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439<strong> translation_func()<\/strong>\u00a0\u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u043d\u0430\u0448\u0435\u043c\u0443 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0442\u0435\u043c \u0436\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u043c <strong>.string<\/strong> .<\/p>\n<pre><code class=\"python\">for child in soup.descendants:     if child.name not in tag_exeption and child.name and child.string:     child.string = translation_func(child.string)<\/code><\/pre>\n<p>\u0422\u0435\u0433\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043d\u0430 \u043f\u0440\u044f\u043c\u0443\u044e \u0442\u0435\u043a\u0441\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <strong>.contents<\/strong>, \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u044f \u0438\u043c\u0435\u043d\u0430 \u0442\u0435\u0433\u043e\u0432 (<strong>not content.name<\/strong>), \u043f\u0440\u043e\u0431\u0435\u043b\u044b \u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044b <strong>[&#8216;\\n&#8217;, &#8216; &#8216;].\u00a0<\/strong><\/p>\n<pre><code class=\"python\">elif not child.name in tag_exeption and child.name: #and count &lt; 10: \u00a0\u00a0\u00a0 for content in child.contents:         new_contents = [] \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if content.string and content.string not in ['\\n', ' '] and not content.name: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0    translation_text = translation_func(content.string) \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 content = NavigableString(translation_text)     \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 new_contents.append(content)      \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new_contents.append(\" \") \u00a0\u00a0 \u00a0child.clear() \u00a0\u00a0\u00a0 child.extend(new_contents)<\/code><\/pre>\n<p>Beautiful Soup \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0442\u0435\u043a\u0441\u0442\u0430 \u043a\u043b\u0430\u0441\u0441 <strong>NavigableString, <\/strong>\u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<strong> <\/strong>\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430<strong>, <\/strong>\u043e\u0447\u0438\u0449\u0430\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u0430 <strong>child.clear()<\/strong>,\u00a0\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u043e\u0442\u043e\u043c\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>child.extend(new_contents).<\/strong><\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 book \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0432\u0438\u0434\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 soup, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434<strong> .set_content()<\/strong>, \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u044f \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c.\u00a0<\/p>\n<pre><code class=\"python\">item.set_content(soup.encode())<\/code><\/pre>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 book \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <strong>.open_in_browser(contents)<\/strong> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 lxml, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0<a href=\"http:\/\/docs.sourcefabric.org\/projects\/ebooklib\/en\/latest\/index.html#\" rel=\"noopener noreferrer nofollow\"><u>Ebook Lib<\/u><\/a> &#8212; <strong>utils.parse_string(item.get_content()).<\/strong><\/p>\n<p>\u00a0<\/p>\n<pre><code class=\"python\">from ebooklib import epub, utils \u2026 contents = utils.parse_string(item.get_content()) html.open_in_browser(contents)<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e &#8212; \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0434\u0435\u043d\u043d\u0443\u044e \u043a\u043d\u0438\u0433\u0443.<\/p>\n<pre><code class=\"python\">epub.write_epub('new_book.epub', book, {})<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0412\u0435\u0441\u044c \u043a\u043e\u0434\u00a0 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from googletrans import Translator from ebooklib import epub, utils from bs4 import BeautifulSoup, NavigableString import lxml.html as html  def open_epub():     tag_exeption = [\"code\", 'a', 'strong', 'pre', 'span', 'html',                     'div', 'body', \"head\"]     book = epub.read_epub('Django 4 By Example 2022.epub')     for item in book.get_items():         if item.get_id() == \"Chapter_7\":             print('NAME : ', item.get_name())             print('----------------------------------')             print('ID : ', item.get_id())             print('----------------------------------')             print('ITEM : ', item.get_type())              soup = BeautifulSoup(item.get_content(), features=\"xml\")              for child in soup.descendants:                 if child.name not in tag_exeption and child.name and child.string:                     tag_text_before = child.string                     translation_text = translation_func(tag_text_before)                     child.string = translation_text                 elif not child.name in tag_exeption and child.name:                     new_contents = []                     class_attr = child.attrs.get('class')                     for content in child.contents:                         if content.string and content.string not in ['\\n', ' '] and not content.name:                             content = NavigableString(translation_func(content.string))                             new_contents.append(content)                             new_contents.append(\" \")                     child.clear()                     child.extend(new_contents)             item.set_content(soup.encode())             contents = utils.parse_string(item.get_content())             html.open_in_browser(contents)             print('==================================')     epub.write_epub('new_book.epub', book, {})  def translation_func(text):     translator = Translator()     result = translator.translate(text, dest='ru')     return result.text  def main():     open_epub()  if __name__ == \"__main__\":     main()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c\u00a0\u043f\u0440\u043e \u0444\u0430\u0439\u043b\u044b CSS, \u0432 \u043a\u043d\u0438\u0433\u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \u0442\u0438\u043f\u0430 ITEM_STYLE = 2 \u0438\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 <a href=\"https:\/\/sigil-ebook.com\/\" rel=\"noopener noreferrer nofollow\"><u>Sigil &#8212; EPUB Editor<\/u><\/a> \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043d\u0438\u0433\u0438,<\/p>\n<p>\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043e\u043d\u0438 \u0432 \u043f\u0430\u043f\u043a\u0435 Styles.<\/p>\n<pre><code class=\"xml\">&lt;head> \u00a0\u00a0&lt;title>Example book&lt;\/title> \u00a0\u00a0&lt;link href=\"..\/Styles\/epub.css\" rel=\"stylesheet\" type=\"text\/css\"\/> \u00a0\u00a0&lt;link href=\"..\/Styles\/syntax-highlighting.css\" rel=\"stylesheet\" type=\"text\/css\"\/> &lt;\/head><\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043d\u0438\u0433\u0438 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 CSS \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b <a href=\"https:\/\/sigil-ebook.com\/\" rel=\"noopener noreferrer nofollow\"><u>Sigil &#8212; EPUB Editor<\/u><\/a>, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-342803","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=342803"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342803\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=342803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=342803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=342803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}