NodeJS Proxy İle Fetch Kullanımı
Node-fetch kütüphanesini isteklerinizde proxy kullanacak şekilde yapılandırabilirsiniz bu işlem çok kolaydır. Node-fetch kütüphanesi ile proxy kullanımı 2 ye ayrılır ve şöyledir.
HTTP tabanlı proxyler için kullanım ;
1 -) $ npm install https-proxy-agent
var HttpProxyAgent = require('http-proxy-agent');
const fetch = require("node-fetch")
fetch('http://site.com/', {agent: new HttpProxyAgent('http://ip:port')})
.then(function (res) {
console.log(res)
})
HTTPS tabanlı proxyler için kullanım ;
1 -) $ npm install https-proxy-agent
var HttpsProxyAgent = require('https-proxy-agent');
const fetch = require("node-fetch")
fetch('https://www.site.com/', {agent: new HttpsProxyAgent('http://ip:port')})
.then(function (res) {
console.log(res)
})
Yorumlar
Yorum Gönder