File size: 1,545 Bytes
540e13c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Import the modules
const express = require('express');
const axios = require('axios');

// Create an express app
const app = express();

// Define a route for the root path
app.all('/', async (req, res) => {
  // Initialize a counter for the loop
  let count = 0;
  // Initialize a flag for the success
  let success = false;
  // Loop until success or 10 times
  while (!success && count < 10) {
    try {
      // Fetch the cookies from the given URL
      let response = await axios.get('https://proxybing.nbing.eu.org/turing/captcha/challenge');
      //let response = await axios.get('https://bing.cf03-b29.workers.dev/turing/captcha/challenge');
      // Set the success flag to true
      success = true;
      // Get the cookies from the response header
      let cookies = response.headers['set-cookie'];
      // Remove all the "Path=/" from the cookies
      cookies = cookies.map(cookie => cookie.replace('Path=/', ''));
      // Join the cookies with semicolons
      cookies = cookies.join('; ');
      // Create a JSON object with the cookies as a property
      let result = {result: {cookies: cookies}};
      // Return the JSON object as the body of the response
      res.json(result);
    } catch (error) {
      // Increment the counter
      count++;
    }
  }
  // If the loop ends without success, return an error message
  if (!success) {
    res.status(500).send('Failed to get cookies');
  }
});

// Run the express app, listen on port 7860
app.listen(7860, () => {
  console.log('App is running on port 7860');
});