Advertisement
dereksir

Untitled

Mar 13th, 2023
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. const axios = require('axios');
  2.  
  3. const proxyList = [
  4. { ip: '198.59.191.234', port: '8080' },
  5. { ip: '200.105.215.22', port: '33630' },
  6. { ip: '125.17.80.229', port: '8080' },
  7. ]; // Replace with your own list of proxies
  8.  
  9. // Function to rotate through the list of proxies
  10. const rotateProxy = () => {
  11. const proxy = proxyList.shift(); // Get the next available proxy
  12. proxyList.push(proxy); // Add the current proxy back to the end of the list
  13. return `http://${proxy.ip}:${proxy.port}`;
  14. }
  15.  
  16. // Function to make a request using Axios with a rotating proxy
  17. const makeRequest = async () => {
  18. try {
  19. const response = await axios.get('https://example.com', {
  20. proxy: rotateProxy(),
  21. timeout: 10000,
  22. });
  23. console.log(response.data);
  24. } catch (error) {
  25. console.error(error);
  26. }
  27. }
  28.  
  29. // Call the makeRequest function for each request you want to make
  30. makeRequest();
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement