Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // import required libraries
- const axios = require('axios');
- const cheerio = require('cheerio');
- // make an HTTP GET request to the target URL with proxy settings
- axios.get('https://httpbin.org/ip',
- {
- proxy: {
- protocol: 'http',
- host: '159.65.221.25',
- port: 80,
- },
- }
- )
- .then(response => {
- // log the response data
- console.log(response.data);
- // HTTPBin returns a JSON reponse, which Cheerio cannot parse.
- // if your target website returns HTML, you can parse using Cheerio as follows
- // const $ = cheerio.load(response.data)
- // const textContent = $('body').text();
- // console.log(textContent);
- })
- .catch(error => {
- console.error('Error:', error);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement