javascript - 如何检索 xpath 的内部文本?
问题描述
我想要来自 xpath 的内部文本
我正在尝试这个,但到目前为止我无法得到文本
const download = await frame.$x(xpath);
const downloadText = await download[0].getProperty('textContent');
console.log(downloadText);
结果是,以下
JSHandle {
...
_targetType: 'page',
_sessionId: '14CCB014112B47319CA8A1C810F23B18'
},
_remoteObject: { type: 'string', value: '20200129_1500.zip' },
_disposed: false
}
我想检索 _remoteObject 中的值,我已经尝试了几乎所有我找到的东西,但似乎没有什么对我有用。
请帮帮我。
解决方案
这工作得很好!
const text = await (await download[0].getProperty('textContent')).jsonValue();
推荐阅读
- python - 如何控制内部的 Gtk.Frame 和 Gtk.HBox 之间的距离?
- php - PHP url 路由和漂亮的 url
- julia - 使用另一个函数作为参数调用一个函数会引发错误
- actions-on-google - 尝试调用 Google 登录助手上的操作时收到语音匹配错误
- java - Okhttp3 - RequestBody.create(contentType, content) 已弃用
- actionscript-3 - 错误 #1502:脚本执行的时间超过了默认 > 15 秒的超时时间
- rust - Rust 中的指针式常量内存类型
- python - 对 pandas 数据框中的时间序列数据进行着色
- android - 无法在 android studio 中构建新项目
- .net - 如何在 startup.cs 中运行/触发服务?