Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
769 B
1
Indexable
Never
const request = require('request');
const cheerio = require('cheerio');

const url = '';
const selector = '.font-1rem';
let previousText = 'Current Bid : 1.50';

function checkForChanges() {
  request(url, (error, response, html) => {
    if (!error && response.statusCode == 200) {
      const $ = cheerio.load(html);
      const currentText = $(selector).text();
      if (currentText !== previousText) {
        console.log(`Text value has changed from "${previousText}" to "${currentText}"`);
        previousText = currentText;
        // Stop the interval
        clearInterval(intervalId);
      } else {
        console.log('Text value has not changed');
      }
    }
  });
}


const intervalId = setInterval(checkForChanges, 10000);