Reputation: 113
I'm trying to access the data in a without success I tried all the documentation that I found without success hope for help from a genius ...
request(
"https://www.answers.com/Q/What_are_examples_of_prefixes_and_suffixes",
(error, response, html) => {
if (!error && response.statusCode == 200) {
let $ = cheerio.load(html)
// here what can i do to find the data for the <script>
console.log((str = $("script")[0].children[0].data))
console.log("Scraping Done...")
} else {
console.log("Scrapping Failed")
console.log(error)
}
}
)
hope for help to access this object...
Upvotes: 2
Views: 377
Reputation: 54984
Just use regex on the whole response:
json = html.match(/window.appConfig = (\{.*\})/)[1]
Upvotes: 2