我正在尝试通过Puppeteer进行一些基本的抓取。我尤其要在以下布局中提取foo
div的文本内容。
<div class="foobar">
<div class="foo">…</div>
</div>
这有效:
const foobar = page.$eval('.foobar foo', (el => el.textContent));
const [foo] = await Promise.all([foobar]);
console.log(foo);
但是我想从包含DOM对象的变量中提取元素。阅读Puppeteer's ElementHandle class documentation我希望这会得到相同的结果:
const foobar = page.$('.foobar');
const [bar] = await Promise.all([foobar]);
const foo = bar.$eval('.foo', (el => el.textContent));
console.log(foo);
但是我从console.log(foo)
得到的全部是
承诺{
}
并且脚本挂起,或者如果我关闭Puppeteer浏览器,它将失败并
UnhandledPromiseRejectionWarning:未处理的承诺被拒绝
我想念什么?
答案 0 :(得分:0)
好像您错过了library(shiny)
ui <- fluidPage(
selectInput("country", "Select country", list(
"Europe" = c("Germany", "Spain"),
"North America" = c("Canada", "United States" = "USA")
)),
selectInput("country", "Select country", list(
"Europe" = c("Germany", "Spain"),
"North America" = c("Canada", "")
))
)
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
。
应该是:
await