我想使用Node.js从这个网站获取信息。 正如您所见,有一个表格要编译。 我希望在选择时获取信息:
SelectedBy: Country, area or territory
Filter by: Austria, Bulgaria, Croatia, Cyprus, Germany
Year from: 1995
Week from: 1
Year to: 2018
Week to: 53
然后我想下载例如结果的Excel文件。 我怎么能这样做?
通常我会这样做:
var countries = {
'Austria': 'AUT',
'Bulgaria': 'BGR',
'Croatia': 'HRV',
'Cyprus': 'CYP',
'Germany': 'DEU'
};
function download() {
for(country in countries) {
var url = 'http://apps.who.int/immunization_monitoring/globalsummary/incidences?c=' + countries[country];
request(url, (function(country) {
var thisCountry = country;
return function(error, res, html) {
if(error) {
throw error;
}
// send html response to cheerio to create DOM
$ = cheerio.load(html);
// some code...
}
})(country));
}
};
但在这种情况下,此代码显然不起作用。