fundamentus-unofficial-api icon indicating copy to clipboard operation
fundamentus-unofficial-api copied to clipboard

quotationHistory.test.js failed

Open jcsilva opened this issue 3 years ago • 1 comments

Hi,

I tried to run the tests/quotationHistory.test.js, but I got this error:

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)

   5 | async function scrapQuotationHistory (share) {
   6 |   const response = await getPage(endpoints.quotationHistory, share)
>  7 |   const data = JSON.parse(response.serialize().replace(/<.+>/g, ''))
     |                     ^
   8 |   return data.map(item => {
   9 |     return {
  10 |       date: new Date(item[0]).toISOString().slice(0, 10),

  at scrapQuotationHistory (lib/scrappers/quotationHistory/index.js:7:21)
  at Object.getQuotationHistory (lib/scrappers/quotationHistory/index.js:17:16)
  at Object.<anonymous> (tests/quotationHistory.test.js:6:28)

I tried to investigate a bit and it seems the server is always responding nothing. Maybe you have already faced this issue and could, please, indicate how to solve this issue.

jcsilva avatar Aug 02 '21 11:08 jcsilva

I also had the same issue and it turns out that the endpoint for quotationHistory is returning a blank page. I don't know if the website has changed the way of having historical quotes, or if the link has changed. in utils.js const endpoints = { details: 'https://fundamentus.com.br/detalhes.php?papel=', quotationHistory: 'https://fundamentus.com.br/amline/cot_hist.php?papel=', earningsHistory: 'https://www.fundamentus.com.br/proventos.php?tipo=1&papel=' }

edudossa avatar Aug 31 '21 16:08 edudossa