This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getExchangeRate = (from, to) => { | |
return axios.get(`http://api.fixer.io/latest?base=${from}`).then((res)=> { | |
return res.data.rates[to] | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getCountries = (currencyCode) => { | |
return axios.get(`https://restcountries.eu/rest/v2/currency/${currencyCode}`).then((res)=> { | |
return res.data.map((country)=> country.name) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const convertCurrency = (from, to, amount) => { | |
let countries | |
return getCountries(to).then((tempCountries) => { | |
countries = tempCountries | |
return getExchangeRate(from, to) | |
}).then((rate) => { | |
const exchangedAmount = amount * rate | |
return `${amount} ${from} is worth ${exchangedAmount} ${to}. ${to} can be used in the following countries: ${countries.join(', ')}` | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const convertCurrencyAlt = async (from, to, amount) => { | |
const countries = await getCountriesAlt(to) | |
const rate = await getExchangeRateAlt(from, to) | |
const exchangedAmount = amount * rate | |
return `${amount} ${from} is worth ${exchangedAmount} ${to}. ${to} can be used in the following countries: ${countries.join(', ')}` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [ | |
'h1', | |
'h2', | |
'h3' | |
] | |
const arr2 = [ | |
'p1', | |
'p2', | |
'p3', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Horseman = require('node-horseman'); | |
var horseman = new Horseman(); | |
horseman | |
.open('http://www.angeloni.com.br/super/index') | |
.status() | |
.evaluate(function(){ | |
const descNode = document.querySelectorAll('.descr a') | |
const desc = Array.prototype.map.call(descNode, function (t) { return t.textContent }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TelegramBot = require('node-telegram-bot-api') | |
const TOKEN = '123345567:AAABBBCCCDDD1A22RbCdTyoIjYaTek' | |
const bot = new TelegramBot(TOKEN, { polling: true }) | |
bot.on('new_chat_members', (msg) => { | |
bot.sendMessage(msg.chat.id, `Olá ${msg.from.first_name}, bem vindo ao Devs SC!! Conte-nos um pouco sobre você, com o que trabalha e onde, se possivel é claro`) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bot.onText(/\/eventos (.+)/, (msg, match) => { | |
const chatId = msg.chat.id | |
const resp = normalizer(match[1].trim()) | |
const urlTec = `https://www.sympla.com.br/eventos/${resp}?s=tecnologia` | |
axios.get(urlTec).then((response) => { | |
const $ = cheerio.load(response.data) | |
const data = [] | |
$('.event-box-link').each((i, elm) => { | |
data.push({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const defaultDiacriticsRemovalMap = [{ | |
'base': "A", | |
'letters': /(A|Ⓐ|A|À|Á|Â|Ầ|Ấ|Ẫ|Ẩ|Ã|Ā|Ă|Ằ|Ắ|Ẵ|Ẳ|Ȧ|Ǡ|Ä|Ǟ|Ả|Å|Ǻ|Ǎ|Ȁ|Ȃ|Ạ|Ậ|Ặ|Ḁ|Ą|Ⱥ|Ɐ|[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F])/g | |
}, { | |
'base': "AA", | |
'letters': /(Ꜳ|[\uA732])/g | |
}, { | |
'base': "AE", | |
'letters': /(Æ|Ǽ|Ǣ|[\u00C6\u01FC\u01E2])/g | |
}, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Módulo dotenv (variaveis do sistema) | |
require('dotenv').config({path: '../.env'}) | |
//Modulo para monitorar a pasta com arquivo da programação | |
const fs = require('fs') | |
//Modulo para leitura do xlsx | |
const xlsx = require('node-xlsx') | |
//Modulo para trabalhar com datas |
OlderNewer