calibre - en to zh_CN translation catalogue (68 entries)

en: Adding your favorite news website
zh_CN: 添加你喜欢的新闻站点

en: calibre has a powerful, flexible and easy-to-use framework for downloading news from the Internet and converting it into an e-book. The following will show you, by means of examples, how to get news from various websites.
zh_CN: caliber有一个强大，灵活且易于使用的框架，用于从Internet下载新闻并将其转换为电子书。 以下将通过示例向您展示如何从各种网站获取新闻。

en: To gain an understanding of how to use the framework, follow the examples in the order listed below:
zh_CN: 要了解如何使用框架，请按照下面列出的顺序执行示例：

en: Completely automatic fetching
zh_CN: 完全自动获取

en: If your news source is simple enough, calibre may well be able to fetch it completely automatically, all you need to do is provide the URL. calibre gathers all the information needed to download a news source into a :term:`recipe`. In order to tell calibre about a news source, you have to create a :term:`recipe` for it. Let's see some examples:
zh_CN: 如果你的新闻来源足够简单，Calibre很可能能够完全自动获取它，你所需要做的就是提供URL。Calibre收集下载新闻源到`Receipe`所需的所有信息。为了告诉Calibre关于一个新闻源的信息，你必须为它创建一个“Receipe”。让我们来看一些例子：

en: The calibre blog
zh_CN: calibre博客

en: The calibre blog is a blog of posts that describe many useful calibre features in a simple and accessible way for new calibre users. In order to download this blog into an e-book, we rely on the :term:`RSS` feed of the blog::
zh_CN: calibre 博客是一个帖子博客，以简单易懂的方式为新 calibre 用户描述许多有用的 calibre 功能。 为了将此博客下载成电子书，我们依赖博客的“RSS”提要：

en: I got the RSS URL by looking under "Subscribe to" at the bottom of the blog page and choosing :guilabel:`Posts->Atom`. To make calibre download the feeds and convert them into an e-book, you should right click the :guilabel:`Fetch news` button and then the :guilabel:`Add a custom news source` menu item and then the :guilabel:`New Recipe` button. A dialog similar to that shown below should open up.
zh_CN: 我通过查看博客页面底部的“订阅”并选择“Posts->Atom”获得了 RSS URL。 要使 calibre 下载提要并将其转换为电子书，您应该右键单击“获取新闻”按钮，然后单击“添加自定义新闻源”菜单项，然后单击“新新闻源”按钮。 应该会打开一个类似于下图所示的对话框。

en: First enter ``Calibre Blog`` into the :guilabel:`Recipe title` field. This will be the title of the e-book that will be created from the articles in the above feeds.
zh_CN: 首先在“新闻源标题”字段中输入“Calibre Blog”。 这将是根据上述提要中的文章创建的电子书的标题。

en: The next two fields (:guilabel:`Oldest article` and :guilabel:`Max. number of articles`) allow you some control over how many articles should be downloaded from each feed, and they are pretty self explanatory.
zh_CN: 接下来的两个字段（“最旧的文章”和“最大文章数”）允许您控制应该从每个提要下载多少文章，并且它们非常不言自明。

en: To add the feeds to the recipe, enter the feed title and the feed URL and click the :guilabel:`Add feed` button. Once you have added the feed, simply click the :guilabel:`Save` button and you're done! Close the dialog.
zh_CN: 要将提要添加到新闻源中，请输入提要标题和提要 URL，然后单击“添加提要”按钮。 添加提要后，只需单击“保存”按钮即可完成！ 关闭对话框。

en: To test your new :term:`recipe`, click the :guilabel:`Fetch news` button and in the :guilabel:`Custom news sources` sub-menu click :guilabel:`calibre Blog`. After a couple of minutes, the newly downloaded e-book of blog posts will appear in the main library view (if you have your reader connected, it will be put onto the reader instead of into the library). Select it and hit the :guilabel:`View` button to read!
zh_CN: 要测试新的“新闻源”，请单击“获取新闻”按钮，然后在“自定义新闻源”子菜单中单击“calibre Blog”。 几分钟后，新下载的博客文章电子书将出现在主书库视图中（如果您连接了阅读器，它将被放入阅读器而不是书库中）。 选择它并点击“查看”按钮即可阅读！

en: The reason this worked so well, with so little effort is that the blog provides *full-content* :term:`RSS` feeds, i.e., the article content is embedded in the feed itself. For most news sources that provide news in this fashion, with *full-content* feeds, you don't need any more effort to convert them to e-books. Now we will look at a news source that does not provide full content feeds. In such feeds, the full article is a webpage and the feed only contains a link to the webpage with a short summary of the article.
zh_CN: 这种方法效果如此之好、花费如此之少的原因是博客提供了“完整内容”“RSS”提要，即文章内容嵌入在提要本身中。 对于大多数以这种方式提供新闻的新闻源，通过“完整内容”提要，您不需要更多的努力将它们转换为电子书。 现在我们将看看不提供完整内容提要的新闻源。 在此类提要中，完整的文章是一个网页，并且提要仅包含指向该网页的链接以及文章的简短摘要。

en: Let's try the following two feeds from *The BBC*:
zh_CN: 让我们尝试一下来自 *The BBC* 的以下两个提要：

en: News Front Page: https://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml
zh_CN: 新闻头版：https://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml

en: Science/Nature: https://newsrss.bbc.co.uk/rss/newsonline_world_edition/science/nature/rss.xml
zh_CN: 科学/自然：https://newsrss.bbc.co.uk/rss/newsonline_world_edition/science/nature/rss.xml

en: Follow the procedure outlined in :ref:`calibre_blog` above to create a recipe for *The BBC* (using the feeds above). Looking at the downloaded e-book, we see that calibre has done a creditable job of extracting only the content you care about from each article's webpage. However, the extraction process is not perfect. Sometimes it leaves in undesirable content like menus and navigation aids or it removes content that should have been left alone, like article headings. In order, to have perfect content extraction, we will need to customize the fetch process, as described in the next section.
zh_CN: 按照上面“calibre_blog”中概述的过程为 *The BBC* 创建新闻源（使用上面的提要）。 查看下载的电子书，我们发现 calibre 做得工作非常出色，它只从每篇文章的网页中提取您关心的内容。 然而，提取过程并不完美。 有时，它会留下不需要的内容，例如菜单和导航辅助工具，或者删除本应保留的内容，例如文章标题。 为了实现完美的内容提取，我们需要自定义获取过程，如下一节所述。

en: Customizing the fetch process
zh_CN: 自定义获取过程

en: When you want to perfect the download process, or download content from a particularly complex website, you can avail yourself of all the power and flexibility of the :term:`recipe` framework. In order to do that, in the :guilabel:`Add custom news sources` dialog, simply click the :guilabel:`Switch to Advanced mode` button.
zh_CN: 当您想要完善下载过程或从特别复杂的网站下载内容时，您可以利用“recipe”框架的所有功能和灵活性。 为此，在“添加自定义新闻源”对话框中，只需单击“切换到高级模式”按钮即可。

en: The easiest and often most productive customization is to use the print version of the online articles. The print version typically has much less cruft and translates much more smoothly to an e-book. Let's try to use the print version of the articles from *The BBC*.
zh_CN: 最简单且通常最有效的定制是使用在线文章的印刷版。 印刷版通常没有那么繁琐，并且可以更顺利地转换为电子书。 让我们尝试使用 *The BBC* 文章的印刷版。

en: Using the print version of bbc.co.uk
zh_CN: 使用 bbc.co.uk 的印刷版

en: The first step is to look at the e-book we downloaded previously from :ref:`bbc`. At the end of each article, in the e-book is a little blurb telling you where the article was downloaded from. Copy and paste that URL into a browser. Now on the article webpage look for a link that points to the "Printable version". Click it to see the print version of the article. It looks much neater! Now compare the two URLs. For me they were:
zh_CN: 第一步是查看我们之前从“bbc”下载的电子书。 在电子书中每篇文章的末尾都有一个小简介，告诉您该文章是从哪里下载的。 将该 URL 复制并粘贴到浏览器中。 现在，在文章网页上查找指向“可打印版本”的链接。 单击它可查看文章的打印版本。 看起来整洁多了！ 现在比较两个 URL。 对我来说，他们是：

en: Article URL
zh_CN: 文章 URL

en: Print version URL
zh_CN: 打印版 URL

en: So it looks like to get the print version, we need to prefix every article URL with:
zh_CN: 所以看起来要获取打印版本，我们需要在每篇文章的 URL 前加上以下前缀：

en: Now in the :guilabel:`Advanced mode` of the Custom news sources dialog, you should see something like (remember to select *The BBC* recipe before switching to advanced mode):
zh_CN: 现在，在“自定义新闻源”对话框的“高级模式”中，您应该看到类似的内容（请记住在切换到高级模式之前选择 *The BBC* 菜谱）：

en: You can see that the fields from the :guilabel:`Basic mode` have been translated to Python code in a straightforward manner. We need to add instructions to this recipe to use the print version of the articles. All that's needed is to add the following two lines:
zh_CN: 您可以看到“基本模式”中的字段已以简单的方式转换为 Python 代码。 我们需要向此新闻源添加说明以使用文章的打印版本。 所需要做的就是添加以下两行：

en: This is Python, so indentation is important. After you've added the lines, it should look like:
zh_CN: 这是Python，所以缩进很重要。 添加这些行后，它应该如下所示：

en: In the above, ``def print_version(self, url)`` defines a *method* that is called by calibre for every article. ``url`` is the URL of the original article. What ``print_version`` does is take that url and replace it with the new URL that points to the print version of the article. To learn about `Python <https://www.python.org>`_ see the `tutorial <https://docs.python.org/tutorial/>`_.
zh_CN: 在上面，“def print_version(self, url)”定义了一个由 calibre 为每篇文章调用的*方法*。 ``url`` 是原始文章的 URL。 print_version 的作用是获取该 url 并将其替换为指向文章打印版本的新 URL。 要了解“Python <https://www.python.org>”_，请参阅“教程 <https://docs.python.org/tutorial/>”_。

en: Now, click the :guilabel:`Add/update recipe` button and your changes will be saved. Re-download the e-book. You should have a much improved e-book. One of the problems with the new version is that the fonts on the print version webpage are too small. This is automatically fixed when converting to an e-book, but even after the fixing process, the font size of the menus and navigation bar become too large relative to the article text. To fix this, we will do some more customization, in the next section.
zh_CN: 现在，单击“添加/更新新闻源”按钮，您的更改将被保存。 重新下载电子书。 你应该有一本改进了很多的电子书。 新版本的问题之一是印刷版网页上的字体太小。 当转换为电子书时，此问题会自动修复，但即使在修复过程之后，菜单和导航栏的字体大小相对于文章文本也变得太大。 为了解决这个问题，我们将在下一节中进行更多自定义。

en: Replacing article styles
zh_CN: 替换文章样式

en: In the previous section, we saw that the font size for articles from the print version of *The BBC* was too small. In most websites, *The BBC* included, this font size is set by means of :term:`CSS` stylesheets. We can disable the fetching of such stylesheets by adding the line::
zh_CN: 在上一节中，我们看到 *The BBC* 印刷版文章的字体太小。 在大多数网站包括 *BBC* 中，此字体大小是通过“CSS”样式表设置的。 我们可以通过添加以下行来禁用此类样式表的获取：

en: The recipe now looks like:
zh_CN: 新闻源现在看起来像：

en: The new version looks pretty good. If you're a perfectionist, you'll want to read the next section, which deals with actually modifying the downloaded content.
zh_CN: 新版本看起来还不错。 如果您是完美主义者，您将需要阅读下一节，其中涉及实际修改下载的内容。

en: Slicing and dicing
zh_CN: 数据交叉分析

en: calibre contains very powerful and flexible abilities when it comes to manipulating downloaded content. To show off a couple of these, let's look at our old friend the :ref:`The BBC <bbc1>` recipe again. Looking at the source code (:term:`HTML`) of a couple of articles (print version), we see that they have a footer that contains no useful information, contained in
zh_CN: 在操作下载内容方面，calibre 包含非常强大且灵活的功能。 为了展示其中的一些，让我们再次看看我们的老朋友“BBC <bbc1>”新闻源。 查看几篇文章（打印版）的源代码（“HTML”），我们看到它们的页脚不包含任何有用的信息，包含在

en: This can be removed by adding::
zh_CN: 可以通过添加以下内容来删除它：

en: to the recipe. Finally, lets replace some of the :term:`CSS` that we disabled earlier, with our own :term:`CSS` that is suitable for conversion to an e-book::
zh_CN: 对新闻源。 最后，让我们用我们自己的适合转换为电子书的“CSS”替换我们之前禁用的一些“CSS”：

en: With these additions, our recipe has become "production quality".
zh_CN: 通过这些添加，我们的配方已成为“生产质量”。

en: This :term:`recipe` explores only the tip of the iceberg when it comes to the power of calibre. To explore more of the abilities of calibre we'll examine a more complex real life example in the next section.
zh_CN: 当谈到calibre的能力时，这个“秘诀”只探索了冰山一角。 为了探索 calibre 的更多功能，我们将在下一节中研究一个更复杂的现实生活示例。

en: Real life example
zh_CN: 现实生活中的例子

en: A reasonably complex real life example that exposes more of the :term:`API` of ``BasicNewsRecipe`` is the :term:`recipe` for *The New York Times*
zh_CN: 一个相当复杂的现实生活示例，公开了“BasicNewsRecipe”的更多“API”，是“纽约时报”的“recipe”

en: We see several new features in this :term:`recipe`. First, we have::
zh_CN: 我们在这个“新闻源”中看到了几个新功能。 首先，我们有:

en: This sets the displayed time on the front page of the created e-book to be in the format, ``Day, Day_Number Month, Year``. See :attr:`timefmt <calibre.web.feeds.news.BasicNewsRecipe.timefmt>`.
zh_CN: 这会将创建的电子书首页上的显示时间设置为“日，日_数字月，年”格式。 请参阅“timefmt <calibre.web.feeds.news.BasicNewsRecipe.timefmt>”。

en: Then we see a group of directives to cleanup the downloaded :term:`HTML`::
zh_CN: 然后我们看到一组指令来清理下载的“HTML”：

en: These remove everything before the first ``<h1>`` tag and everything after the first tag whose id is ``footer``. See :attr:`remove_tags <calibre.web.feeds.news.BasicNewsRecipe.remove_tags>`, :attr:`remove_tags_before <calibre.web.feeds.news.BasicNewsRecipe.remove_tags_before>`, :attr:`remove_tags_after <calibre.web.feeds.news.BasicNewsRecipe.remove_tags_after>`.
zh_CN: 这些会删除第一个“<h1>”标签之前的所有内容以及第一个 id 为“footer”的标签之后的所有内容。 请参阅 `remove_tags <calibre.web.feeds.news.BasicNewsRecipe.remove_tags>`、`remove_tags_before <calibre.web.feeds.news.BasicNewsRecipe.remove_tags_before>`、`remove_tags_after <calibre.web.feeds.news.BasicNewsRecipe.remove_tags_after> `。

en: The next interesting feature is::
zh_CN: 下一个有趣的功能是：

en: ``needs_subscription = True`` tells calibre that this recipe needs a username and password in order to access the content. This causes, calibre to ask for a username and password whenever you try to use this recipe. The code in :meth:`calibre.web.feeds.news.BasicNewsRecipe.get_browser` actually does the login into the NYT website. Once logged in, calibre will use the same, logged in, browser instance to fetch all content. See `mechanize <https://mechanize.readthedocs.io/en/latest/>`_ to understand the code in ``get_browser``.
zh_CN: ``needs_subscription = True`` 告诉 calibre 该菜谱需要用户名和密码才能访问内容。 这会导致每当您尝试使用此配方时，calibre 都会要求输入用户名和密码。`calibre.web.feeds.news.BasicNewsRecipe.get_browser` 中的代码实际上登录了《纽约时报》网站。 登录后，calibre 将使用相同的已登录浏览器实例来获取所有内容。 请参阅 `mechanize <https://mechanize.readthedocs.io/en/latest/>`_ 以了解 `get_browser` 中的代码。

en: The next new feature is the :meth:`calibre.web.feeds.news.BasicNewsRecipe.parse_index` method. Its job is to go to https://www.nytimes.com/pages/todayspaper/index.html and fetch the list of articles that appear in *todays* paper. While more complex than simply using :term:`RSS`, the recipe creates an e-book that corresponds very closely to the days paper. ``parse_index`` makes heavy use of `BeautifulSoup <https://www.crummy.com/software/BeautifulSoup/bs4/doc/>`_ to parse the daily paper webpage. You can also use other, more modern parsers if you dislike BeautifulSoup. calibre comes with `lxml <https://lxml.de/>`_ and `html5lib <https://github.com/html5lib/html5lib-python>`_, which are the recommended parsers. To use them, replace the call to ``index_to_soup()`` with the following::
zh_CN: 下一个新功能是“calibre.web.feeds.news.BasicNewsRecipe.parse_index”方法。 它的 工作是访问 https://www.nytimes.com/pages/todayspaper/index.html 并获取 *todays* 报纸中出现的文章列表。 虽然比简单地使用“RSS”更复杂，但该方法创建了一本与每日报纸非常接近的电子书。 ``parse_index`` 大量使用 `BeautifulSoup <https://www.crummy.com/software/BeautifulSoup/bs4/doc/>`_ 来解析日报网页。 如果您不喜欢 BeautifulSoup，您也可以使用其他更现代的解析器。 calibre 附带 `lxml <https://lxml.de/>`_ 和 `html5lib <https://github.com/html5lib/html5lib-python>`_，这是推荐的解析器。 要使用它们，请将对“index_to_soup()”的调用替换为以下内容：

en: The final new feature is the :meth:`calibre.web.feeds.news.BasicNewsRecipe.preprocess_html` method. It can be used to perform arbitrary transformations on every downloaded HTML page. Here it is used to bypass the ads that the nytimes shows you before each article.
zh_CN: 最后一个新功能是“calibre.web.feeds.news.BasicNewsRecipe.preprocess_html”方法。 它可用于对每个下载的 HTML 页面执行任意转换。 这里它用于绕过纽约时报在每篇文章之前向您展示的广告。

en: Tips for developing new recipes
zh_CN: 开发新新闻源的技巧

en: The best way to develop new recipes is to use the command line interface. Create the recipe using your favorite Python editor and save it to a file say :file:`myrecipe.recipe`. The `.recipe` extension is required. You can download content using this recipe with the command::
zh_CN: 开发新新闻源的最佳方法是使用命令行界面。 使用您最喜欢的 Python 编辑器创建新闻源并将其保存到文件名为 “myrecipe.recipe”的文件中。 需要“.recipe”扩展名。 您可以使用此新闻源通过以下命令下载内容：

en: The command :command:`ebook-convert` will download all the webpages and save them to the EPUB file :file:`myrecipe.epub`. The ``-vv`` option makes ebook-convert spit out a lot of information about what it is doing. The :option:`ebook-convert-recipe-input --test` option makes it download only a couple of articles from at most two feeds. In addition, ebook-convert will put the downloaded HTML into the ``debug/input`` folder, where ``debug`` is the folder you specified in the :option:`ebook-convert --debug-pipeline` option.
zh_CN: 命令“ebook-convert”将下载所有网页并将它们保存到 EPUB 文件“myrecipe.epub”。 “-vv”选项使 ebook-convert 吐出大量有关其正在执行的操作的信息。 “ebook-convert-recipe-input --test”选项使其最多只能从两个提要中下载几篇文章。 此外，ebook-convert 会将下载的 HTML 放入“debug/input”文件夹中，其中“debug”是您在“ebook-convert --debug-pipeline”选项中指定的文件夹。

en: Once the download is complete, you can look at the downloaded :term:`HTML` by opening the file :file:`debug/input/index.html` in a browser. Once you're satisfied that the download and preprocessing is happening correctly, you can generate e-books in different formats as shown below::
zh_CN: 下载完成后，您可以通过在浏览器中打开文件  `debug/input/index.html`来查看下载的“HTML”。 一旦您对下载和预处理正确进行感到满意，您就可以生成不同格式的电子书，如下所示：

en: If you're satisfied with your recipe, and you feel there is enough demand to justify its inclusion into the set of built-in recipes, post your recipe in the `calibre recipes forum <https://www.mobileread.com/forums/forumdisplay.php?f=228>`_ to share it with other calibre users.
zh_CN: 如果您对自己的新闻源感到满意，并且您认为有足够的需求来证明将其包含在内置新闻源集中，请将您的新闻源发布在“calibre 新闻源论坛”<https://www.mobileread.com/forums/forumdisplay.php?f=228>`_ 与其他 calibre 用户分享。

en: On macOS, the command line tools are inside the calibre bundle, for example, if you installed calibre in :file:`/Applications` the command line tools are in :file:`/Applications/calibre.app/Contents/MacOS/`.
zh_CN: 在 macOS 上，命令行工具位于 calibre 包内，例如，如果您在“/Applications”中安装了 calibre，则命令行工具位于“/Applications/calibre.app/Contents/MacOS/”中。

en: :doc:`generated/en/ebook-convert`
zh_CN: “生成/en/电子书转换”

en: The command line interface for all e-book conversion.
zh_CN: 所有电子书转换的命令行界面。

en: Further reading
zh_CN: 以后阅读

en: To learn more about writing advanced recipes using some of the facilities, available in ``BasicNewsRecipe`` you should consult the following sources:
zh_CN: 要了解有关使用“BasicNewsRecipe”中提供的某些工具编写高级食谱的更多信息，您应该查阅以下来源：

en: :ref:`API documentation <news_recipe>`
zh_CN: “API文档<news_recipe>”

en: Documentation of the ``BasicNewsRecipe`` class and all its important methods and fields.
zh_CN: “BasicNewsRecipe” 类及其所有重要方法和字段的文档。

en: The source code of ``BasicNewsRecipe``
zh_CN: ``基本新闻源``的源代码

en: `Built-in recipes <https://github.com/kovidgoyal/calibre/tree/master/recipes>`_
zh_CN: `内置新闻源 <https://github.com/kovidgoyal/calibre/tree/master/recipes>`_

en: The source code for the built-in recipes that come with calibre
zh_CN: calibre自带的内置新闻源的源代码

en: `The calibre recipes forum <https://www.mobileread.com/forums/forumdisplay.php?f=228>`_
zh_CN: `calibre 新闻源论坛 <https://www.mobileread.com/forums/forumdisplay.php?f=228>`_

en: Lots of knowledgeable calibre recipe writers hang out here.
zh_CN: 许多知识渊博的新闻源作家都在这里闲逛。

en: API documentation
zh_CN: API文档
