Advertisement
dereksir

Untitled

Mar 6th, 2024 (edited)
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // import required libraries
  2. const axios = require('axios');
  3. const cheerio = require('cheerio');
  4.  
  5. // make an HTTP GET request to the target URL with proxy settings
  6. axios.get('https://httpbin.org/ip',
  7.     {
  8.         proxy: {
  9.             protocol: 'http',
  10.             host: '159.65.221.25',
  11.             port: 80,
  12.         },
  13.     }
  14. )
  15.   .then(response => {
  16.     // log the response data
  17.     console.log(response.data);
  18.    
  19.     // HTTPBin returns a JSON reponse, which Cheerio cannot parse.
  20.    
  21.     // if your target website returns HTML, you can parse using Cheerio as follows
  22.     // const $ = cheerio.load(response.data)
  23.     // const textContent = $('body').text();
  24.     // console.log(textContent);
  25.  
  26.   })
  27.   .catch(error => {
  28.     console.error('Error:', error);
  29.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement