Skip to content

Instantly share code, notes, and snippets.

@alexTitakoff
Created December 26, 2018 14:12
Show Gist options
  • Save alexTitakoff/b1572442fac94ea5d45007879b87036f to your computer and use it in GitHub Desktop.
Save alexTitakoff/b1572442fac94ea5d45007879b87036f to your computer and use it in GitHub Desktop.
простое потягивания данный из getов
let link = 'https://horoscopes.rambler.ru/api/front/v1/horoscope/today/taurus/'
var http = require('http');
// var options = {
// host: 'horoscopes.rambler.ru',
// port: 80,
// path: '/api/front/v1/horoscope/today/taurus/',
// method : 'GET'
// };
// http.get(options, function(res) {
// console.log(res.body, 'res');
// console.log("Got response: " + res.statusCode);
// }).on('error', function(e) {
// console.log("Got error: " + e.message);
// });
// Вариант1
const https = require('https');
let testUrl = 'https://horoscopes.rambler.ru/api/front/v1/horoscope/today/'
parseArr = ['taurus', 'virgo']
parseArr.forEach(element => {
https.get('https://horoscopes.rambler.ru/api/front/v1/horoscope/today/'+element+'/', (resp) => {
let data = '';
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk;
});
// The whole response has been received. Print out the result.
resp.on('end', () => {
console.log(data) // Делай что хочешь
// console.log(JSON.parse(data).explanation);
});
}).on("error", (err) => {
console.log("Error: " + err.message);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment