<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Cheerio Blog</title><description>Updates and announcements from the Cheerio team.</description><link>https://cheerio.js.org/</link><item><title>Cheerio 1.0 Released, Batteries Included 🔋</title><link>https://cheerio.js.org/blog/cheerio-1.0/</link><guid isPermaLink="true">https://cheerio.js.org/blog/cheerio-1.0/</guid><pubDate>Wed, 07 Aug 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Cheerio 1.0 is out! After 12 release candidates and just a short seven years
after the initial 1.0 release candidate, it is finally time to call Cheerio 1.0
complete. The theme for this release is &amp;quot;batteries included&amp;quot;, with common use
cases now supported out of the box.&lt;/p&gt;
&lt;p&gt;So grab a pair of double-As, and read below for what&amp;#39;s new, what&amp;#39;s changed, and
how to upgrade!&lt;/p&gt;
&lt;!--truncate--&gt;&lt;h2&gt;New Website and Documentation&lt;/h2&gt;
&lt;p&gt;Since the last release, we&amp;#39;ve published a new website and documentation for
Cheerio. The new site features detailed guides and API documentation to get the
most from Cheerio. Check it out at &lt;a href=&quot;https://cheerio.js.org/&quot;&gt;cheerio.js.org&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;A new way to load documents&lt;/h2&gt;
&lt;p&gt;Loading documents into Cheerio has been revamped. Cheerio now supports multiple
loading methods, each tailored to different use cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;load&lt;/code&gt;: The classic method for parsing HTML or XML strings.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;loadBuffer&lt;/code&gt;: Works with binary data, automatically detecting the document
encoding.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;stringStream&lt;/code&gt; and &lt;code&gt;decodeStream&lt;/code&gt;: Parse HTML directly from streams.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fromURL&lt;/code&gt;: Fetch and parse HTML from a URL in one go.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Dive deeper into these methods in the &lt;a href=&quot;/docs/basics/loading&quot;&gt;Loading Documents&lt;/a&gt;
tutorial.&lt;/p&gt;
&lt;h2&gt;Simplified Data Extraction&lt;/h2&gt;
&lt;p&gt;The new &lt;code&gt;extract&lt;/code&gt; method allows you to extract data from an HTML document and
store it in an object. To fetch the latest release of Cheerio from GitHub and
extract the release date and the release notes from the release page is now as
simple as:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ts&quot;&gt;import * as cheerio from &amp;#39;cheerio&amp;#39;;

const $ = await cheerio.fromURL(
  &amp;#39;https://github.com/cheeriojs/cheerio/releases&amp;#39;,
);
const data = $.extract({
  releases: [
    {
      // First, we select individual release sections.
      selector: &amp;#39;section&amp;#39;,
      // Then, we extract the release date, name, and notes from each section.
      value: {
        // Selectors are executed within the context of the selected element.
        name: &amp;#39;h2&amp;#39;,
        date: {
          selector: &amp;#39;relative-time&amp;#39;,
          // The actual release date is stored in the `datetime` attribute.
          value: &amp;#39;datetime&amp;#39;,
        },
        notes: {
          selector: &amp;#39;.markdown-body&amp;#39;,
          // We are looking for the HTML content of the element.
          value: &amp;#39;innerHTML&amp;#39;,
        },
      },
    },
  ],
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Read more about all of the available options in the
&lt;a href=&quot;/docs/advanced/extract&quot;&gt;Extracting Data&lt;/a&gt; guide.&lt;/p&gt;
&lt;h2&gt;Breaking Changes and Upgrade Guide&lt;/h2&gt;
&lt;p&gt;Cheerio 1.0 introduces several breaking changes, most notably:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The minimum NodeJS version is now 18.17 or higher.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Import paths were simplified. For example, use &lt;code&gt;cheerio/slim&lt;/code&gt; instead of
&lt;code&gt;cheerio/lib/slim&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The deprecated default Cheerio instance and static methods were removed.&lt;/p&gt;
&lt;p&gt;Before, it was possible to write code like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ts&quot;&gt;import cheerio, { html } from &amp;#39;cheerio&amp;#39;;

html(cheerio(&amp;#39;&amp;lt;test&amp;gt;&amp;lt;/test&amp;gt;&amp;#39;)); // ~ &amp;#39;&amp;lt;test&amp;gt;&amp;lt;/test&amp;gt;&amp;#39; -- NO LONGER WORKS
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Make sure to always load documents first:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ts&quot;&gt;import * as cheerio from &amp;#39;cheerio&amp;#39;;

cheerio.load(&amp;#39;&amp;lt;test&amp;gt;&amp;lt;/test&amp;gt;&amp;#39;).html();
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;htmlparser2 options now reside exclusively under the &lt;code&gt;xml&lt;/code&gt; key:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-ts&quot;&gt;const $ = cheerio.load(&amp;#39;&amp;lt;html&amp;gt;&amp;#39;, {
  xml: {
    withStartIndices: true,
  },
});
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Node types previously re-exported by Cheerio must now be imported directly
from &lt;a href=&quot;https://github.com/fb55/domhandler&quot;&gt;&lt;code&gt;domhandler&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For a comprehensive list of changes, please consult
&lt;a href=&quot;https://github.com/cheeriojs/cheerio/releases&quot;&gt;the changelog&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Upgrading to Cheerio 1.0&lt;/h2&gt;
&lt;p&gt;To upgrade to Cheerio 1.0, just run:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;npm install cheerio@latest
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Get Involved&lt;/h2&gt;
&lt;p&gt;Explore the new features and let us know what you think! Encounter an issue?
Report it on our
&lt;a href=&quot;https://github.com/cheeriojs/cheerio/issues&quot;&gt;GitHub issue tracker&lt;/a&gt;. Have an
idea for an improvement? Pull requests welcome :)&lt;/p&gt;
&lt;h2&gt;Thank You&lt;/h2&gt;
&lt;p&gt;Thanks to &lt;a href=&quot;https://github.com/jugglinmike&quot;&gt;@jugglinmike&lt;/a&gt; for kick-starting
Cheerio 1.0, and to all the contributors who have helped shape this release. We
couldn&amp;#39;t have done it without you.&lt;/p&gt;
&lt;p&gt;Thanks to our
&lt;a href=&quot;https://github.com/cheeriojs/cheerio?sponsor&quot;&gt;sponsors and backers&lt;/a&gt; for
supporting Cheerio&amp;#39;s development. If you use Cheerio at work, consider asking
your company to support us!&lt;/p&gt;
&lt;p&gt;And finally, thank you for using Cheerio 🙇🙇‍♀️&lt;/p&gt;
</content:encoded></item><item><title>New Website, Who Dis?</title><link>https://cheerio.js.org/blog/new-website/</link><guid isPermaLink="true">https://cheerio.js.org/blog/new-website/</guid><pubDate>Mon, 13 Feb 2023 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Cheerio has a new website, and it&amp;#39;s looking pretty good! This has been in the
works for a while, and we&amp;#39;re excited to finally share it with you. Let&amp;#39;s walk
through all that&amp;#39;s new.&lt;/p&gt;
&lt;p&gt;:::note&lt;/p&gt;
&lt;p&gt;Cheerio&amp;#39;s website is still a work-in-progress, and covers Cheerio&amp;#39;s next release
that isn&amp;#39;t available yet.
&lt;a href=&quot;https://github.com/cheeriojs/cheerio/discussions/3002&quot;&gt;We would love your help in making this website better!&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;:::&lt;/p&gt;
&lt;!--truncate--&gt;&lt;h2&gt;Guides&lt;/h2&gt;
&lt;p&gt;The Cheerio website now features a set of guides, helping you get started with
the project. Even if you&amp;#39;ve used the project for a while, you might still learn
something new!&lt;/p&gt;
&lt;p&gt;Most of these guides were written with the help of
&lt;a href=&quot;https://chat.openai.com/&quot;&gt;ChatGPT&lt;/a&gt;, which made it possible to generate
high-quality content in a reasonable amount of time. While contents have been
checked for accuracy, we are happy to accept pull requests to improve the
guides.&lt;/p&gt;
&lt;p&gt;Get started with the &lt;a href=&quot;/docs/intro&quot;&gt;intro guide&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;API Docs&lt;/h2&gt;
&lt;p&gt;API docs, the old focus of the website, have been moved to a subdirectory. They
are available at &lt;a href=&quot;/docs/api&quot;&gt;docs/api&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Blog&lt;/h2&gt;
&lt;p&gt;We&amp;#39;re also starting a blog, where we&amp;#39;ll share updates about the project. Feel
free to subscribe &lt;a href=&quot;/blog/rss.xml&quot;&gt;to the RSS feed&lt;/a&gt;!&lt;/p&gt;
</content:encoded></item></channel></rss>