Answer the question
In order to leave comments, you need to log in
How to recognize Russian when receiving XML in nodejs?
Good afternoon.
I'm trying to get exchange rates from cbr. As a result, I get XML with unrecognized Cyrillic. Where should I write it, please?
The code
const xml2js = require('xml2js');
const util = require('util');
const parser = new xml2js.Parser();
var http = require('http');
//The url we want is: 'www.random.org/integers/?num=1&min=1&max=10&col=1&base=10&format=plain&rnd=new'
var options = {
host: 'www.cbr.ru',
path: '/scripts/XML_daily.asp?date_req=02/03/2002'
};
callback = function(response) {
var str = '';
//another chunk of data has been received, so append it to `str`
response.on('data', function (chunk) {
str += chunk;
});
//the whole response has been received, so we just print it out here
response.on('end', function () {
parser.parseString(str, (err, result) => {
console.log(util.inspect(result, false, null, true));
})
});
}
http.request(options, callback).end();
Answer the question
In order to leave comments, you need to log in
Getting a task from the cart - nginx-uwsgi-(django / flask / handmade wsgi )
Depending on how long the parser works
- start it in the same thread that received the request from the user
- create a queue (celery) and work through it
If it happens that parsers fall (and they certainly fall), then celery is unambiguous.
More complex workflows - dask.distributed. Celery canvas is very limited.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question