@0xtld/tair-node
Version:
A Node.js package for Tair functionality with configuration, core, and helper modules.
33 lines (24 loc) • 865 B
text/typescript
import { UrbanProxy } from './core/urban-proxy';
async function testUrbanProxy() {
const urbanProxy = new UrbanProxy();
console.log('Now:', Date.now());
try {
console.log('Fetching proxy list...');
const proxyList = await urbanProxy.getProxyList();
console.log('Proxy list fetched:', proxyList.length);
console.log('Fetching a proxy...');
const proxy = await urbanProxy.getProxy();
console.log('Proxy fetched:', proxy);
if (!proxy) {
throw new Error('Proxy not found');
}
const remainingTime = proxy.expiration_time - Date.now();
console.log('Remaining time:', remainingTime);
console.log('Fetching IP using the proxy...');
const ip = await urbanProxy.getIp(proxy);
console.log('IP fetched:', ip);
} catch (error) {
console.error('Error during testing:', error);
}
}
testUrbanProxy();