Search code examples
htmlnode.jscheerio

Cheerio changing single quotas into double


I am using cheerio to modify HTML that i am scraping from a website. However it is messing up quoats.

This script works fine, the only issue is, it is changing ' to "

       // Load in HTML
       $ = cheerio.load(string);
       console.log($.html());   

It is changing:

     <script>window.jQuery || document.write("<script src='//cdn.shopify.com/s/files/1/0967/6522/t/2/assets/jquery.min.js?15981737959390328713'>\x3C/script>")</script>

To:

    <script>window.jQuery || document.write("<script src="//cdn.shopify.com/s/files/1/0967/6522/t/2/assets/jquery.min.js?15981737959390328713">\x3C/script>")</script>

Solution

  • It looks like you ran into issue #720 on the Cheerio issue tracker. They said they won't fix it, but you might convince them with your use case. I suggest commenting on the issue there.