SHARE
TWEET

Untitled

a guest Feb 27th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is your Editor pane. Write your JavaScript here and
  2. // use the command line to execute commands
  3. const rp = require('request-promise');
  4.  
  5. servers_url = 'https://lobby.ogame.gameforge.com/api/servers';
  6. user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/73.0';
  7.  
  8. var options = {
  9.     method: 'GET',
  10.     uri: servers_url,
  11.     headers: {
  12.     'User-Agent': user_agent,
  13.     },
  14.     resolveWithFullResponse: true,
  15.     json: true
  16. };
  17.  
  18. function get_servers() {
  19.     response = rp(options);
  20.     response.then(response => {
  21.       //console.log(response.body);
  22.       const results = response.body.filter(d =>
  23.         //d.language === 'en' &&
  24.         d.playerCount < 80 &&
  25.         d.settings.economySpeed > 4 &&
  26.         d.settings.fleetSpeed > 2 &&
  27.         (d.language === 'jp' ||
  28.         d.language === 'si')
  29.         );
  30.     console.log('filtered out:', results);
  31.     console.log('Universe number: ', results[0].number)
  32.       console.log(response.statusCode);
  33.     });
  34.     return response;
  35. }
  36. get_servers();
  37. //console.log(get_servers());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top