Replies: 3 comments 3 replies
-
After retrying many times, can put back the correct data, but have to retry many times each time. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Use Axios to put back the correct dataThe code above returns the same data as the browser. const axios = require('axios');
const cheerio = require('cheerio')
axios.get(
'https://www.amazon.com/dp/B002ZVOLXE'
).then((res) => {
const $ = cheerio.load(res.data)
// Amazon.com : Greenworks 20-Inch 3-in-1 12 Amp Electric Corded Lawn Mower 25022 : Walk Behind Lawn Mowers : Garden & Outdoor
console.log($('title').text())
}) But, the following code will have to be retried many times to return the above data. How do I configure Option to return the data each time? const got = require('got');
const cheerio = require('cheerio');
(async () => {
const res = await got('https://www.amazon.com/dp/B002ZVOLXE', {
// xxx
}
);
if(res.statusCode === 200) {
const $ = cheerio.load(res.body)
// Sorry, we just need to make sure you're not a robot. For best results, please make sure your browser is accepting cookies.
console.log($('p.a-last').text())
}
})(); PLS help me? |
Beta Was this translation helpful? Give feedback.
2 replies
-
You could try to set the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
url: https://www.amazon.com/dp/B002ZVOLXE
content: Sorry, we just need to make sure you're not a robot. For best results, please make sure your browser is accepting cookies.
What do I need to do to access my Amazon data correctly?
Beta Was this translation helpful? Give feedback.
All reactions