Jquery 无法抓取正确的数据

Jquery 无法抓取正确的数据,jquery,node.js,web-scraping,Jquery,Node.js,Web Scraping,我想从下面的url抓取德里的当前温度。我在和MEAN stack一起工作。我对jQuery了解不多。有时我会出错: { [Error: socket hang up] code: 'ECONNRESET' } 有时我会得到一周的温度。如何获得那样的温度?帮帮我 api.get('/scrape', function (req, res) { url = "http://www.timeanddate.com/weather/india/new-delhi";

我想从下面的url抓取德里的当前温度。我在和MEAN stack一起工作。我对jQuery了解不多。有时我会出错:

{ [Error: socket hang up] code: 'ECONNRESET' }
有时我会得到一周的温度。如何获得那样的温度?帮帮我

 api.get('/scrape', function (req, res) {



        url = "http://www.timeanddate.com/weather/india/new-delhi";
        request(url,function(error,response,html) {
            if (!error) {
                var $ = cheerio.load(html);
                var title, release, rating;
                var json = {title: "", release: "", rating: ""};
                $('.').filter(function () {
                    var data = $(this);
                    title = data.children().first().text();
                    release = data.children().last().children().text();
                    json.title = title;
                    json.release = release;
                });

                console.log('before');

                var data=$('div.rows').find('span');

                console.log(data.text());

                console.log('after');
            }
            else
            {
                console.log(error);
            }

        });

    });

你很可能会偶尔收到EconReset,因为他们的网站速度很慢…

正如我所说的,使用api比使用网页抓取更可靠

此请求多久发送一次?您可能希望定期发送(每5分钟一次?)并存储结果,然后使用存储的结果进行响应,而不是在每次需要时进行刮取。(也可能有一个Web服务,你可以用它来代替抓取…)当用户重新加载一个我们需要临时数据的页面时,它会被发送,这是每小时一次吗?每分钟200次?每隔一段时间请求一次,只需返回上一次成功的值,直到另一次请求成功更新该值,即可减少网络错误。为什么不使用api,如:如何知道站点是否慢。我的意思是选择哪个站点来爬网当前的温度。@Rayof希望如果你正在抓取其他人的站点,总有可能出现网络错误。请将“请求超时”选项设置为较大的值(例如600秒)。这可能会有帮助…如何做到这一点?我必须在这个api中设置吗?请求({url:url,timeout:600},函数(error,response,html))我发现这个方法有问题。但我需要在3小时内在我们的网站上删除新德里临时工并提交。你能帮我找出一个方法,让我可以在我的api中进行更改吗。
console.log('before');
console.log($('.current-tem').find('span').html().substr(0,5));