【发布时间】:2021-12-28 22:08:30
【问题描述】:
我得到一个
referenceError: 终端 A 未定义
在第 48 行。我不确定自己做错了什么。
writeStream.write(`Terminal A,Terminal B,Terminal C/D \n`);
var minutes = 1, timerInerval = minutes * 60 * 1000;
function TerminalOccupancyData() {
request('https://www.laguardiaairport.com/to-from-airport/parking', (error, response, html) => {
// Check there is no error
if (!error && response.statusCode == 200) {
// using cheerio library to load the website page html
const $ = cheerio.load(html);
$('.terminal-left').each((span, el) => {
// Find the element using the class
const terminalA = $(el)
.find('.terminal-percentage')
.text()
.replace(/% Full/, '');
const terminalB = $(el)
.find('.terminal-percentage')
.text()
.replace(/% Full/, '');
const terminalCD = $(el)
.find('.terminal-percentage')
.text()
.replace(/% Full/, '');
});
console.log('\nTerminal Data scraped ... \n');
}
});
// Export to file to upload to database
writeStream.write(`${terminalA},${terminalB},${terminalCD} \n`);
}
setInterval(TerminalOccupancyData, timerInerval);
【问题讨论】:
标签: node.js csv web-scraping export-to-csv