import {HttpsProxyAgent} from 'https-proxy-agent';
export async function getLinkApi() {
try {
// let response = await fetch("https://livefootball.su/wp-json/wp/v2/pages");
let response = await fetch('https://livefootball.su/wp-json/wp/v2/pages',{ agent:new HttpsProxyAgent('http://176.31.129.223:8080')});
const data = await response.json();
let link = "";
import fetch from 'node-fetch'; // Подключите библиотеку fetch, если еще не подключили
import { HttpsProxyAgent } from 'https-proxy-agent';
export async function getLinkApi() {
try {
const proxyAgent = new HttpsProxyAgent('http://176.31.129.223:8080');
const response = await fetch('https://livefootball.su/wp-json/wp/v2/pages', {
agent: proxyAgent,
headers: {
// Если требуется, добавьте дополнительные заголовки
// 'Authorization': 'Bearer YourAccessToken',
// 'User-Agent': 'YourUserAgent',
},
});
const data = await response.json();
const link = ""; // Обработка данных
return link;
} catch (error) {
console.error('Error fetching data:', error);
throw error;
}
}
const { ProxyAgent } = require('undici');
const proxy = {
'host': 'xxx.xxx.xxx.xxx',
'port': 'xxx',
'username': 'xxx',
'password': '***',
};
const proxyAgent = new ProxyAgent({
uri: `http://${proxy.host}:${proxy.port}`,
token: `Basic ${Buffer.from(`${proxy.username}:${proxy.password}`).toString('base64')}`,
});
(async () => {
const data = await fetch('https://httpbin.org/get', { dispatcher: proxyAgent });
const json = await data.json();
await proxyAgent.close();
console.log(json);
})();