yahoo-exchange
Advanced tools
Comparing version 1.5.5 to 1.5.6
37
index.js
@@ -5,7 +5,2 @@ "use strict"; | ||
const arrayLen24 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
const regexpList = [ | ||
/<!-- react-text: 36 -->([0-9.,]+)/gmi, | ||
/<!-- react-text: 38 -->([0-9.,]+)/gmi, | ||
/<!-- react-text: 39 -->([0-9.,]+)/gmi | ||
]; | ||
const remove = (str, remove) => { | ||
@@ -18,14 +13,21 @@ if (typeof str === 'string') | ||
const parseHTML = html => parseR(html.toString())(36); | ||
const parseHTML2 = (html, r) => [parseFloat(remove(regexpList[0].exec(html)[1], ',')), | ||
html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 2).split(' ')[0]) : | ||
parseFloat(regexpList[2].exec(html)[1].split(' ')[0]), | ||
html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 2).split('(')[1].split("\%")[0]) : | ||
parseFloat(regexpList[2].exec(html)[1].split('(')[1].split("\%")[0]), r(42), r(48), r(54), r(71), | ||
parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[0], ',')), | ||
parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[2].split('<')[0], ',')), | ||
parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[0], ',')), | ||
parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[2].split('<')[0], ',')) | ||
]; | ||
const parseHTML2 = (html, r) => { | ||
const list = []; | ||
list.push(parseFloat(remove(/<!-- react-text: 36 -->([0-9.,]+)/gmi.exec(html)[1], ','))); | ||
list.push(html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 3).split(' ')[0]) : | ||
parseFloat(parseReact(html, 39, 1).split(' ')[0])); | ||
list.push(html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 3).split('(')[1].split("\%")[0]) : | ||
parseFloat(parseReact(html, 39, 1).split('(')[1].split("\%")[0])); | ||
list.push(r(42)); | ||
list.push(r(48)); | ||
list.push(r(54)); | ||
list.push(r(71)); | ||
list.push(parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[0], ','))); | ||
list.push(parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[2].split('<')[0], ','))); | ||
list.push(parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[0], ','))); | ||
list.push(parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[2].split('<')[0], ','))); | ||
return list; | ||
}; | ||
const req = (pair, errorHandler, callback) => request({ | ||
@@ -43,2 +45,3 @@ url: `https://finance.yahoo.com/quote/${pair}=X?p=${pair}=X`, | ||
errorHandler(e, 'yahoo-exchange: Unknown Error'); | ||
console.log(e); | ||
} | ||
@@ -45,0 +48,0 @@ }); |
37
index.ts
import request = require('request'); | ||
const arrayLen24 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
const regexpList = [ | ||
/<!-- react-text: 36 -->([0-9.,]+)/gmi, | ||
/<!-- react-text: 38 -->([0-9.,]+)/gmi, | ||
/<!-- react-text: 39 -->([0-9.,]+)/gmi | ||
]; | ||
const remove = (str: string, remove: string) => { | ||
@@ -15,14 +10,21 @@ if (typeof str === 'string') return str.replace(remove, ''); | ||
const parseHTML = html => parseR(html.toString())(36); | ||
const parseHTML2 = (html: string, r: Function) => [parseFloat(remove(regexpList[0].exec(html)[1], ',')), | ||
html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 2).split(' ')[0]) : | ||
parseFloat(regexpList[2].exec(html)[1].split(' ')[0]), | ||
html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 2).split('(')[1].split("\%")[0]) : | ||
parseFloat(regexpList[2].exec(html)[1].split('(')[1].split("\%")[0]), r(42), r(48), r(54), r(71), | ||
parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[0], ',')), | ||
parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[2].split('<')[0], ',')), | ||
parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[0], ',')), | ||
parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[2].split('<')[0], ',')) | ||
]; | ||
const parseHTML2 = (html: string, r: Function) => { | ||
const list = []; | ||
list.push(parseFloat(remove(/<!-- react-text: 36 -->([0-9.,]+)/gmi.exec(html)[1], ','))); | ||
list.push(html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 3).split(' ')[0]) : | ||
parseFloat(parseReact(html, 39, 1).split(' ')[0])); | ||
list.push(html.indexOf('react-text: 39 -->') === -1 ? | ||
parseFloat(parseReact(html, 38, 3).split('(')[1].split("\%")[0]) : | ||
parseFloat(parseReact(html, 39, 1).split('(')[1].split("\%")[0])); | ||
list.push(r(42)); | ||
list.push(r(48)); | ||
list.push(r(54)); | ||
list.push(r(71)); | ||
list.push(parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[0], ','))); | ||
list.push(parseFloat(remove(html.split('data-reactid="61">')[2].split(' ')[2].split('<')[0], ','))); | ||
list.push(parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[0], ','))); | ||
list.push(parseFloat(remove(html.split('data-reactid="65">')[3].split(' ')[2].split('<')[0], ','))); | ||
return list; | ||
}; | ||
const req = (pair, errorHandler, callback) => request({ | ||
@@ -37,2 +39,3 @@ url: `https://finance.yahoo.com/quote/${pair}=X?p=${pair}=X`, | ||
errorHandler(e, 'yahoo-exchange: Unknown Error'); | ||
console.log(e); | ||
} | ||
@@ -39,0 +42,0 @@ }); |
@@ -14,3 +14,3 @@ { | ||
"main": "index.js", | ||
"version": "1.5.5", | ||
"version": "1.5.6", | ||
"license": "MIT", | ||
@@ -17,0 +17,0 @@ "dependencies": { |
@@ -7,3 +7,2 @@ const index = require('../index'); | ||
index.getExchangeDataLowTrafficP().then(v => console.log(v)); | ||
index.getExchangeDataArray('USDKRW', data => console.log(data)); | ||
index.getExchangeDataArray(['USDKRW', 'JPYKRW'], data => console.log(data)); | ||
@@ -13,2 +12,3 @@ index.getExchangeDataArray('USDKRW', (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.getExchangeDataArray(['USDKRW', 'JPYKRW'], (data, pair) => console.log(data, pair), (error, pair) => console.log(`[Error] ${pair}\n${error}`)); | ||
index.getExchangeDataArray('JPYKRW', data => console.log(data)); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
366
521041