yahoo-exchange
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -38,3 +38,3 @@ "use strict"; | ||
}, (err, response, html) => { | ||
let h = html.toString().split(`data-reactid=\"43\">`)[2]; | ||
let h = html.toString().split(`data-reactid=\"75\"`)[2]; | ||
if (err) | ||
@@ -44,3 +44,3 @@ reject(err); | ||
const pair = h.match(/>(...\/...)/gmi); | ||
const price = h.match(/">([0-9,.])+/gmi); | ||
const price = h.match(/">([0-9,.]+)/gmi); | ||
const changes = h.match(/ -->[^0-9reactspa/><\-]*[0-9.\-]+/gmi); | ||
@@ -57,3 +57,3 @@ resolve(arrayLen24.map((v, a) => [remove(pair[a], '>'), parseFloat(remove(price[a], '\">')), parseFloat(remove(changes[a * 2], " -->")), parseFloat(remove(changes[a * 2 + 1], ' -->'))])); | ||
}, (err, response, html) => { | ||
let h = html.toString().split(`data-reactid=\"43\">`)[2]; | ||
let h = html.toString().split(`data-reactid=\"75\"`)[2]; | ||
if (err) | ||
@@ -63,3 +63,3 @@ errorHandler(err); | ||
const pair = h.match(/>(...\/...)/gmi); | ||
const price = h.match(/">([0-9,.])+/gmi); | ||
const price = h.match(/">([0-9,.]+)/gmi); | ||
const changes = h.match(/ -->[^0-9reactspa/><\-]*[0-9.\-]+/gmi); | ||
@@ -66,0 +66,0 @@ callback(arrayLen24.map((v, a) => [remove(pair[a], '>'), parseFloat(remove(price[a], '\">')), parseFloat(remove(changes[a * 2], " -->")), parseFloat(remove(changes[a * 2 + 1], ' -->'))])); |
10
index.ts
@@ -29,2 +29,3 @@ import request = require("request"); | ||
}); | ||
export function getExchangeDataLowTrafficP(): Promise<Array<Array<any>>> { | ||
@@ -35,7 +36,7 @@ return new Promise<Array<Array<any>>>(((resolve, reject) => request({ | ||
}, (err, response, html) => { | ||
let h = html.toString().split(`data-reactid=\"43\">`)[2]; | ||
let h = html.toString().split(`data-reactid=\"75\"`)[2]; | ||
if (err) reject(err); | ||
else { | ||
const pair = h.match(/>(...\/...)/gmi); | ||
const price = h.match(/">([0-9,.])+/gmi); | ||
const price = h.match(/">([0-9,.]+)/gmi); | ||
const changes = h.match(/ -->[^0-9reactspa/><\-]*[0-9.\-]+/gmi); | ||
@@ -46,2 +47,3 @@ resolve(arrayLen24.map((v, a) => [remove(pair[a], '>'), parseFloat(remove(price[a], '\">')), parseFloat(remove(changes[a * 2], " -->")), parseFloat(remove(changes[a * 2 + 1], ' -->'))])); | ||
} | ||
export function getExchangeDataLowTraffic(callback: (data: Array<Array<any>>) => any, errorHandler: (error: Error, pair?: String) => any = err => console.log(err)): void { | ||
@@ -52,7 +54,7 @@ request({ | ||
}, (err, response, html) => { | ||
let h = html.toString().split(`data-reactid=\"43\">`)[2]; | ||
let h = html.toString().split(`data-reactid=\"75\"`)[2]; | ||
if (err) errorHandler(err); | ||
else { | ||
const pair = h.match(/>(...\/...)/gmi); | ||
const price = h.match(/">([0-9,.])+/gmi); | ||
const price = h.match(/">([0-9,.]+)/gmi); | ||
const changes = h.match(/ -->[^0-9reactspa/><\-]*[0-9.\-]+/gmi); | ||
@@ -59,0 +61,0 @@ callback(arrayLen24.map((v, a) => [remove(pair[a], '>'), parseFloat(remove(price[a], '\">')), parseFloat(remove(changes[a * 2], " -->")), parseFloat(remove(changes[a * 2 + 1], ' -->'))])); |
@@ -14,3 +14,3 @@ { | ||
"main": "index.js", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"license": "MIT", | ||
@@ -17,0 +17,0 @@ "dependencies": { |
@@ -12,10 +12,10 @@ const index = require('../index'); | ||
index.getFxYahooJapan(v => console.log(v)); | ||
// index.getFxYahooJapan(v => console.log(v)); | ||
index.getExchangeDataLowTraffic(v => console.log(v)); | ||
index.getExchangeDataLowTrafficP().then(v => console.log(v)); | ||
index.getExchangeDataArray('USDKRW', data => console.log(data)); | ||
index.getExchangeDataArray(['USDKRW', 'JPYKRW'], data => console.log(data)); | ||
index.getExchangeDataArray('USDKRW', (data, pair) => console.log(data, pair)); | ||
index.getExchangeDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair)); | ||
index.getExchangeDataArray('USDKRW', (data, pair) => console.log(data, pair), (error, pair) => console.log(`[Error] ${pair}\n${error}`)); | ||
index.getExchangeDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair), (error, pair) => console.log(`[Error] ${pair}\n${error}`)); | ||
// index.getExchangeDataLowTrafficP().then(v => console.log(v)); | ||
// index.getExchangeDataArray('USDKRW', data => console.log(data)); | ||
// index.getExchangeDataArray(['USDKRW', 'JPYKRW'], data => console.log(data)); | ||
// index.getExchangeDataArray('USDKRW', (data, pair) => console.log(data, pair)); | ||
// index.getExchangeDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair)); | ||
// index.getExchangeDataArray('USDKRW', (data, pair) => console.log(data, pair), (error, pair) => console.log(`[Error] ${pair}\n${error}`)); | ||
// index.getExchangeDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair), (error, pair) => console.log(`[Error] ${pair}\n${error}`)); |
Sorry, the diff of this file is not supported yet
1047348