Fetch free proxies from https://www.free-proxy-list.com
- Fetch HTTP/HTTPS proxies
- Promise and async/await support
- ES6 class support
- Get proxies in medium and high speed
- Non-Chinese proxies
- Typescript Typings
Item | Details |
---|---|
System | GNU/Linux (>=2.6.x), macOS (>=10.10.x), Windows (later than XP) |
Environment | Node.js >= 8.2.0 |
# under product mode
$ npm install free-proxy --save
$ yarn add free-proxy
# under development mode
$ npm install free-proxy --save-dev
$ yarn add -D free-proxy
After you finished the installation above, you will have a package free-proxy
in your ./node_modules
directory.
Default module exports in CommonJS style
const ProxyList = require('free-proxy');
const proxyList = new ProxyList();
or
import ProxyList from 'free-proxy';
const proxyList = new ProxyList();
Get proxy list. This function will craw the website and returns an array of proxy list, and some information (e.g. IP address, port, country, etc.) wrapped in a Promise object.
Recommended usage:
let proxies;
try {
proxies = await proxyList.get();
} catch (error) {
throw new Error(error);
}
or alternatively:
proxyList.get()
.then(function (proxies) {
// get proxies here
})
.catch(function (error) {
throw new Error(error);
});
Get list of proxies using a specific protocol. This function will use proxyList.get
and filter the result by protocaol
Recommended usage:
let proxies;
try {
proxies = await proxyList.getByProtocol('https');
} catch (error) {
throw new Error(error);
}
or alternatively:
proxyList.getByProtocol('http')
.then(function (proxies) {
// get proxies here
})
.catch(function (error) {
throw new Error(error);
});
Get proxy list from a specific country. This function will use proxyList.get
and filter the result by countryCode
Recommended usage:
let proxies;
try {
proxies = await proxyList.getByCountryCode('FR');
} catch (error) {
throw new Error(error);
}
or alternatively:
proxyList.getByCountryCode('FR')
.then(function (proxies) {
// get proxies here
})
.catch(function (error) {
throw new Error(error);
});
Get a proxy randomly. Based on proxyList.get()
, this function will get a random item from the results of proxyList.get()
Recommended usage:
let data;
try {
data = await proxyList.random();
} catch (error) {
throw new Error(error);
}
or alternatively:
proxyList.random()
.then(function (data) {
// get data here
})
.catch(function (error) {
throw new Error(error);
});
Get a proxy randomly. Based on proxyList.getByProtocol()
, this function will get a random item from the results of proxyList.get()
Recommended usage:
let data;
try {
data = await proxyList.randomByProtocol('https');
} catch (error) {
throw new Error(error);
}
or alternatively:
proxyList.randomByProtocol('http')
.then(function (data) {
// get data here
})
.catch(function (error) {
throw new Error(error);
});
Get a proxy randomly. Based on proxyList.getByCountryCode()
, this function will get a random item from the results of proxyList.get()
Recommended usage:
let data;
try {
data = await proxyList.randomByCountryCode('FR');
} catch (error) {
throw new Error(error);
}
or alternatively:
proxyList.randomByCountryCode('FR')
.then(function (data) {
// get data here
})
.catch(function (error) {
throw new Error(error);
});
Get a proxy randomly. Based on proxyList.get()
, this function will get a random item from the results of proxyList.get()
. The list is cached the first time the method is invoked and only updated once the cached list runs out of proxies.
Recommended usage:
let data;
try {
data = await proxyList.randomFromCache();
} catch (error) {
throw new Error(error);
}
or alternatively:
proxyList.randomFromCache()
.then(function (data) {
// get data here
})
.catch(function (error) {
throw new Error(error);
});
To run the test suite, go to the root directory of this package, and install dependencies, and then run npm test
or npm run test
:
$ cd /path/to/free-proxy
$ npm install
$ npm test
# or
$ npm run test