在运行了以下内容之后,我很难理解如何阅读Cheerio的回复:
const axios = require('axios')
const cheerio = require('cheerio')
axios.get('https://bulbapedia.bulbagarden.net/wiki/Galar_Route_5')
.then(({data}) => {
const $ = cheerio.load(data)
const tableData = $('table:first').after('span#Hidden_encounters')
console.log(tableData)
})
当我运行上面的代码时,我得到了一个相当长的响应:
LoadedCheerio {
'0': <ref *1> Element {
parent: Element {
parent: [Element],
prev: null,
next: [Text],
startIndex: null,
endIndex: null,
children: [Array],
name: 'div',
attribs: [Object: null prototype],
type: 'tag',
namespace: 'http://www.w3.org/1999/xhtml',
'x-attribsNamespace': [Object: null prototype],
'x-attribsPrefix': [Object: null prototype]
},
prev: null,
next: Text {
parent: [Element],
prev: [Circular *1],
next: [Text],
startIndex: null,
endIndex: null,
data: 'span#Hidden_encounters',
type: 'text'
},
startIndex: null,
endIndex: null,
children: [ [Text], [Element] ],
name: 'table',
attribs: [Object: null prototype] {
class: 'roundy',
style: 'background: #75C977; width: 30%; max-width: 30%; margin-left: 5px; margin-bottom: 5px; border: 3px solid #4AA14D; float:right; text-align:center'
},
type: 'tag',
namespace: 'http://www.w3.org/1999/xhtml',
'x-attribsNamespace': [Object: null prototype] { class: undefined, style: undefined },
'x-attribsPrefix': [Object: null prototype] { class: undefined, style: undefined }
},
length: 1,
options: { xml: false, decodeEntities: true },
_root: <ref *2> LoadedCheerio {
'0': Document {
parent: null,
prev: null,
next: null,
startIndex: null,
endIndex: null,
children: [Array],
type: 'root',
'x-mode': 'no-quirks'
},
length: 1,
options: { xml: false, decodeEntities: true },
_root: [Circular *2]
},
prevObject: <ref *3> LoadedCheerio {
'0': Document {
parent: null,
prev: null,
next: null,
startIndex: null,
endIndex: null,
children: [Array],
type: 'root',
'x-mode': 'no-quirks'
},
length: 1,
options: { xml: false, decodeEntities: true },
_root: [Circular *3]
}
}
我通读了the docs遍,他们似乎没有任何关于如何阅读或解释回应的内容.
我在其他地方搜索过(youtube,这里,duckduckgo),但我没有找到任何资源,真正告诉你如何解释回答.