Hi ,
When we try to get information from yahoo-finance 2 , on rovo agent creation. we get the errror:
15:37:25.781 78e0fcc2-7cea-4859-9c57-184f4732718f Error: No set-cookie header present in Yahoo’s response. Something must have changed, please report.
at (webpack://rovo-agent-rovo/node_modules/yahoo-finance2/dist/cjs/src/lib/getCrumb.js:126:1)
at Generator.next ()
at fulfilled (webpack://rovo-agent-rovo/node_modules/yahoo-finance2/dist/cjs/src/lib/getCrumb.js:5:1)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
the code is use :
import os from “os”;
import path from “path”;
import { FileCookieStore } from “tough-cookie-file-store”;
import yahooFinance from “yahoo-finance2”;
import { ExtendedCookieJar } from “yahoo-finance2”;
import { show } from “./utils”;
import api, { route } from ‘@forge/api’;
import axios from ‘axios’;
import { fetch } from ‘@forge/api’;
export const getSharePrice = async (payload, requestContext) => {
console.log(Payload: ${JSON.stringify(payload)}
);
console.log(Request Context: ${JSON.stringify(requestContext)}
);
const company = ‘AAPL’;//payload.company;
console.log(Get share for company: ${company}
);
const myyahooFinance = require(‘yahoo-finance2’).default;
console.log(‘start yaahoo finace 00’);
const cookiePath = path.join(os.homedir(), “.yf2-cookies.json”);
console.log(‘start yaahoo finace 01’);
const cookieJar = new ExtendedCookieJar(new FileCookieStore(cookiePath));
console.log(‘start yaahoo finace 02’);
yahooFinance.setGlobalConfig({ cookieJar });
console.log(‘start yaahoo finace 22’);
//setInterval(() => {
//yahooFinance._opts.cookieJar.removeAllCookiesSync();
//}, 60_000 * 10);
console.log(‘start yaahoo finace 232’);
const result = await myyahooFinance.quoteSummary(‘AAPL’);