Skip to content

Instantly share code, notes, and snippets.

@isatimur
Created July 7, 2020 09:30
Show Gist options
  • Save isatimur/d44680bbab8e06ae54cccdacda2f266f to your computer and use it in GitHub Desktop.
Save isatimur/d44680bbab8e06ae54cccdacda2f266f to your computer and use it in GitHub Desktop.
Node js example of how fetch FNS open information
var http = require('http');
var express = require('express');
var app = express();
const fetch = require('node-fetch');
app.get('/:inn', function (req, res) {
const {inn} = req.params;
const response = fetch("https://egrul.nalog.ru/", {
"headers": {
"accept": "application/json, text/javascript, */*; q=0.01",
"accept-language": "en-US,en;q=0.9,ru;q=0.8",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest",
"cookie": "top100_id=t1.289463.74161870.1594044135773; last_visit=1594033496101::1594044296101; JSESSIONID=FAA55D5E5155A1302D500BF56127B58B"
},
"referrer": "https://egrul.nalog.ru/index.html",
"referrerPolicy": "no-referrer-when-downgrade",
"body": "vyp3CaptchaToken=&page=&query="+ inn +"&region=&PreventChromeAutocomplete=",
"method": "POST",
"mode": "cors"
}).then(res => res.json())
.then(json => {
console.log(json.t);
return fetch("https://egrul.nalog.ru/search-result/"+json.t+"?r=1594061157093&_=1594061157093", {
"headers": {
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,ru;q=0.8",
"cache-control": "no-cache",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-requested-with": "XMLHttpRequest",
"cookie": "top100_id=t1.289463.74161870.1594044135773; last_visit=1594033496101::1594044296101; JSESSIONID=FAA55D5E5155A1302D500BF56127B58B"
},
"referrer": "https://egrul.nalog.ru/index.html",
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors"
}).then(res=>res.json())
.then(jjson=>{console.log(jjson.rows[0]);
res.send(jjson);
return jjson;})
});
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment