Getting information from a website via jQuery / Javascript

Asked

Viewed 35 times

1

I need to get information from a website every X minutes. I’m testing locally with a fixed HTML but the idea is to make a request every X minutes, get the information and save it somehow. I saw in some questions here on the site that it is not possible to make a GET via localhost for a domain other than your... This is possible if I upload to my server?

jQuery(document).ready(function() {
     //make a request 

     //update the data
     updateData();

     //save somewhere

     reload(10000);

     function reload(time){
        setInterval(function(){
           //make a request 

           //update the data
           updateData();

        }, time);
     }

     function updateData(){
        var table = $('#discount_card_list tbody');
        var totalCards = $('#discount_card_list .card').text();
        var biggestDiscountRow = 0;
        var biggestDiscount = 0.00;

        table.find('tr').each( function(rowIndex, r) {
           var seller = $(this).find('.seller').text(); 
           //discard ebay seller
           if (seller.toLowerCase().indexOf("ebay") >= 0){
              //go to the next iteration and discard the line
              return true;
           }

           var discount = $(this).find('.save').text().replace('%', '');

           if(discount > biggestDiscount) {
              biggestDiscount = discount;
              biggestDiscountRow = $(this);
           }
        });

        console.log('Date: ' + new Date($.now()));
        console.log('Cards: ' + totalCards.trim());
        console.log('Quantity: ' + biggestDiscountRow.find('.quantity').text().trim());
        console.log('Card type: ' + biggestDiscountRow.find('.type').text().trim());
        console.log('Card value: ' + biggestDiscountRow.find('.value').text().trim());
        console.log('Price: ' + biggestDiscountRow.find('.cost').text().trim());
        console.log('Save: ' + biggestDiscountRow.find('.save').text().trim());
        console.log('Shipping: ' + biggestDiscountRow.find('.shipping').text().trim());
        console.log('Seller: ' + biggestDiscountRow.find('.seller').text().trim());
        console.log('---------------------------');
     }
  });
  • Yes, to activate requests to other servers you have to activate CORS.

  • For this to occur this server has to allow CORS?

  • http://answall.com/questions/12363/howto perform requirements-ajax-com-jquery-em-dom%C3%Adnios-diferentes

  • And also http://answall.com/questions/3183/requisi%C3%A7%C3%a3o-ajax-cross-Domain-with-javascript-neat-without-Apis

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.