Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require('axios');
- const proxyList = [
- { ip: '198.59.191.234', port: '8080' },
- { ip: '200.105.215.22', port: '33630' },
- { ip: '125.17.80.229', port: '8080' },
- ]; // Replace with your own list of proxies
- // Function to rotate through the list of proxies
- const rotateProxy = () => {
- const proxy = proxyList.shift(); // Get the next available proxy
- proxyList.push(proxy); // Add the current proxy back to the end of the list
- return `http://${proxy.ip}:${proxy.port}`;
- }
- // Function to make a request using Axios with a rotating proxy
- const makeRequest = async () => {
- try {
- const response = await axios.get('https://example.com', {
- proxy: rotateProxy(),
- timeout: 10000,
- });
- console.log(response.data);
- } catch (error) {
- console.error(error);
- }
- }
- // Call the makeRequest function for each request you want to make
- makeRequest();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement