【发布时间】:2021-06-06 22:49:01
【问题描述】:
const scraper = require("table-scraper"); //scrape a html table
scraper
.get("https://www.gkd.bayern.de/de/meteo/wind/isar/ammerseeboje-16601050/messwerte/tabelle")
//that is the list of wind values for each hour
.then(function (tableData) {
console.log(tableData[1]); //that is the table as an object
})
控制台返回:
[
{ Datum: '05.06.2021 21:00', 'Wind [m/s]': '5,7' },
{ Datum: '05.06.2021 20:00', 'Wind [m/s]': '5,4' },
....
]
tableData[1][0].Datum - ok 定义数据
但是
tableData[1][0].'Wind [m/s]' - 将返回未定义...
我怎样才能获得例如的价值。 5,7?
谢谢
【问题讨论】:
-
试试:
tableData[1][0]['Wind [m/s]'] -
“将返回未定义” — 不,它会抛出语法错误。
标签: javascript