Я пытался удалить сайт, но Интернет использует запрос ajax и использует токен для получения данных JSON. Как передать токен или есть другой способ получить JSON?
Я использую Node Js (request, cheerio) для очистки. я пробовал с базовым запросом на ссылку (вот пример ссылки: "http://lpse.depkes.go.id/eproc4/dt/lelang?draw=1&columns%5B0%5D%5Bdata%5D=0&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=1&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=2&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=3&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=false&columns%5B3%5D%5Borderable%5D=false&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=4&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=true&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=desc&start=0&length=25&search%5Bvalue%5D=&search%5Bregex%5D=false&authenticityToken=36624c05b9a89a02d40023a5aa4fab618c0478f9&_=1573183784040"
вот токен сверху ссылка:
authenticityToken=36624c05b9a89a02d40023a5aa4fab618c0478f9&_=1573183784040
и некоторые заголовки запроса:
headers: {
"Content-Type": "application/json",
"Connection": "keep-alive",
"Accept": "application/json",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36",
"Accept-Language": "en-US,en;q=0.9,id;q=0.8",
}
вот мой код запроса:
exports.makeRequestGet = async (url) => {
console.log(url)
var options = {
method: "GET",
url: url,
headers: {
"Content-Type": "application/json",
"Connection": "keep-alive",
"Accept": "application/json",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "PostmanRuntime/7.19.0",
"Accept-Language": "en-US,en;q=0.9,id;q=0.8",
},
json: true
};
return new Promise((resolve, reject) => {
request(options, function (error, response, body) {
if (error) {
console.log(error)
return reject(error);
};
console.log(response.headers)
return resolve(body)
});
});
};
но результат:
"result":"Bad authenticity token"