node.js - Parsing JSON from HTML -


using nodejs parse json , js variable declared, in html of 3rd party website. easiest way mentioned json variable html , output it?

chunk of html extract mentioned js can seen bellow:

...  <footer>    <div>      <script type="application/ld+json">              {"@context":"http:\/\/schema.org","@type":"breadcrumblist","itemlistelement":[{"@type":"listitem","position":1,"item":{"@id":"https:\/\/www.domain.com\/","image":"https:\/\/assets.domain.com\/img\/facebook\/stuf.png","name":"home"}}]}      </script>      <script>          var api_url = ["https:\/\/api1.domain.com\/api","https:\/\/api2.domain.com\/api","https:\/\/api3.domain.com\/api"],      </script>    </div>  </footer>  ...

the following html parsed xy website using nodejs request.

i tried jsdom, didn't know how select mentioned <script>. regex solution?

in case provided, selector be: footer>div>script:nth-child(2). you're asking for?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -