New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

investing-com-api-v2

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

investing-com-api-v2 - npm Package Compare versions

Comparing version 5.0.4 to 5.0.5

30

api/InvestingApiV2.js

@@ -9,2 +9,3 @@ const puppeteer = require('puppeteer');

__debugger = true;
__intervalAutoClose;

@@ -38,6 +39,5 @@ setDebugger(status) {

this.__checkResponse(results);
let totalPage = (await this.__browser.pages()).length;
let responseLog = JSON.stringify(results);
responseLog = responseLog.length > 50 ? responseLog.substring(0, 50) + '...' : responseLog;
this.__writeLog('info', `[InvestingApiV2/investing] get success ${responseLog}. runtime ${executeTime} ms, ${totalPage} page running.`);
this.__writeLog('info', `[InvestingApiV2/investing] get success ${responseLog}. runtime ${executeTime} ms.`);
return results;

@@ -59,2 +59,28 @@ } catch (err) {

autoClose(maxPage = 20, intervalTime = 1000, timeRestart = 0, processExit = true) {
const __this = this;
this.__writeLog('info', `[InvestingApiV2/autoClose] enabled auto close max page ${maxPage}, interval ${intervalTime}, timeRestart ${timeRestart}`);
this.__intervalAutoClose = setInterval(async function() {
if (__this.__browser) {
let totalPage = (await __this.__browser.pages()).length;
__this.__writeLog('info', `[InvestingApiV2/autoClose] total page running ${totalPage}, max page ${maxPage}.`);
if (totalPage >= maxPage) {
__this.__writeLog('warn', `[InvestingApiV2/autoClose] max page > total page, shutdown in ${timeRestart} using processExit ${processExit}`);
setTimeout(function() {
if (processExit) {
process.exit(0);
} else {
__this.close();
}
}, timeRestart);
}
}
}, intervalTime);
}
async clearAutoClose() {
this.__writeLog('info', `[InvestingApiV2/clearAutoClose] disabled auto close successfully`);
if (this.__intervalAutoClose) clearInterval(this.__intervalAutoClose);
}
async __callInvesting(pairId, period, interval, pointsCount) {

@@ -61,0 +87,0 @@ let page = await this.__browser.newPage();

2

package.json
{
"name": "investing-com-api-v2",
"version": "5.0.4",
"version": "5.0.5",
"description": "Unofficial APIs for Investing.com website.",

@@ -5,0 +5,0 @@ "main": "api/InvestingApiV2.js",

@@ -7,3 +7,4 @@ const InVestingApiV2 = require('../api/InvestingApiV2');

//enable debugger
InVestingApiV2.setDebugger(false);
InVestingApiV2.setDebugger(true);
InVestingApiV2.autoClose(1);

@@ -19,6 +20,8 @@ //startup browser

60);
console.log(data);
console.log(data[0]);
//close browser
await InVestingApiV2.close();
// await InVestingApiV2.close();
})();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc