- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我试图在速卖通中获取评论,但由于某些原因,wait()
函数总是找不到 #transction-feedback
所以从技术上讲,如果您转到该链接并点击“反馈”,它会显示所有评论
.click 确实有效,因为它单击了选项卡,但似乎 #transction-feedback
从未出现过。我尝试使用浏览器重新创建相同的内容,#transction-feedback
出现了。
这是代码
const cheerio = require('cheerio')
const Nightmare = require('nightmare')
const nightmare = Nightmare({
show: true
})
const URL = 'https://www.aliexpress.com/item/Samsung-Earphones-EHS64-Headsets-With-Built-in-Microphone-3-5mm-In-Ear-Wired-Earphone-For-Smartphones/32854052487.html?spm=2114.search0103.3.1.51dd26c3CxZ3zZ&ws_ab_test=searchweb0_0,searchweb201602_8_10065_10068_319_10059_10884_317_10887_10696_321_322_10084_453_10083_454_10103_10618_10307_537_536,searchweb201603_50,ppcSwitch_0&algo_expid=5587ff37-5e3a-45a8-8206-7b182433a961-0&algo_pvid=5587ff37-5e3a-45a8-8206-7b182433a961'
nightmare
.goto(URL)
.click('li[data-trigger="feedback"]')
.wait('#transction-feedback')
.evaluate(() => {
return document.body.innerHTML
})
.end()
.then((result) => {
const $ = cheerio.load(result)
res.json($.html())
})
.catch(error => {
console.error('Search failed:', error)
})
我也尝试过 Puppeteer,但没有用
const puppeteer = require('puppeteer');
const URL = 'https://www.aliexpress.com/item/Samsung-Earphones-EHS64-Headsets-With-Built-in-Microphone-3-5mm-In-Ear-Wired-Earphone-For-Smartphones/32854052487.html?spm=2114.search0103.3.1.51dd26c3CxZ3zZ&ws_ab_test=searchweb0_0,searchweb201602_8_10065_10068_319_10059_10884_317_10887_10696_321_322_10084_453_10083_454_10103_10618_10307_537_536,searchweb201603_50,ppcSwitch_0&algo_expid=5587ff37-5e3a-45a8-8206-7b182433a961-0&algo_pvid=5587ff37-5e3a-45a8-8206-7b182433a961'
async function testPupp() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(URL);
await page.evaluate(() => {
document.querySelector('li[data-trigger="feedback').click();
console.log(document.body.innerHTML)
});
await browser.close();
}
testPupp()
我该怎么办?
最佳答案
iframe 是问题所在:试试这段代码
const puppeteer = require("puppeteer");
const URL =
"https://www.aliexpress.com/item/Samsung-Earphones-EHS64-Headsets-With-Built-in-Microphone-3-5mm-In-Ear-Wired-Earphone-For-Smartphones/32854052487.html?spm=2114.search0103.3.1.51dd26c3CxZ3zZ&ws_ab_test=searchweb0_0,searchweb201602_8_10065_10068_319_10059_10884_317_10887_10696_321_322_10084_453_10083_454_10103_10618_10307_537_536,searchweb201603_50,ppcSwitch_0&algo_expid=5587ff37-5e3a-45a8-8206-7b182433a961-0&algo_pvid=5587ff37-5e3a-45a8-8206-7b182433a961";
async function testPupp() {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto(URL, { waitUntil: "networkidle2" });
// evade popup
await page.click("body");
await page.keyboard.press("Escape");
await page.click('li[data-trigger="feedback');
// wait for iframe to load
await page.waitFor(2000);
const frame = (await page.frames()).find(f => f.url().includes("feedback"));
await frame.waitFor("#transction-feedback");
await frame.waitFor(".feedback-item");
const els = await frame.$$(".feedback-item");
for (const el of els) {
const text = await (await el.getProperty("textContent")).jsonValue();
console.log(text.trim().replace(/\s\s+/g, " "));
}
await browser.close();
}
testPupp();
关于node.js - .wait() nightmare 和 Puppeteer evaluate 都找不到 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55791269/
我最近刚跨过木偶继承。围绕它的几个问题: 使用p继承是一种好习惯吗?一些经验丰富的木偶同事告诉我,木偶的继承不是很好,我不太相信。 来自OO世界,我真的很想了解木偶继承的原理,以及覆盖的原理。 最佳答
需要一个 puppet 特工联系一些不同 puppet 师。 原因:不同的组创建了不同且独立的 list 集。 可能的组及其任务 应用程序供应商:应用程序的配置 安全性:强化 运营:路由表、监控工具
您可以在 puppet 中制作子模块吗,例如... puppet_root - modules - module_1 - submodule - manifes
在执行类 mypackage 中的代码之前,我需要执行类 mysql,tomcat。在我的 site.pp 我有 node 'node1' { include mysql,mypackage,tomc
我试图从失败的请求和js错误中收集数据。 我正在使用以下网站:https://nitzani1.wixsite.com/marketing-automation/3rd-page 该网站有一个对htt
我在 Suse 11 Linux 机器上使用 puppet 2.7.19 和 facter 1.6.0。 $::osfamily因子变量未设置,尽管它确实有 $::operatingsystem事实集
我正在使用 Puppet 开源版本。 我发现 Puppet 3.7.5 中有几个组件: puppet 大师 puppet 代理 MCollective 希拉 puppet 数据库 但我不知道他们是如何
主要目标是自动添加所有 puppet 模块,以便可以使用一个命令启动所有 dev-env 和 prod-env。如何通过 puppet manifest 安装 puppet 模块? 最佳答案 我们一直
我的 Puppet list 中有一系列 exec: 第一个下载带有二进制文件的 ZIP 文件(除非已经安装了二进制文件)并将其保存到 /tmp。 第二个将其解压缩。 当我第一次应用 list 时,它
我使用 aws opsworks 创建了 puppet master。我可以将 ami linux 节点自动添加到 puppet master。 当我尝试通过此链接 https://puppet.co
关于 this 的另一个问题问题。 有没有办法puppet module install从我已经下载到磁盘的本地存储库安装的工具? 最佳答案 您可以使用Puppet Library托管您自己的私有(p
我可以通过 Puppet Enterprise Master 到 Agent 运行几乎所有其他命令,但更新命令不会运行。据我所知,PE确实以root身份运行。 有人可以建议如何让这个命令在 Linux
我只想在 puppeteer 中刚刚打开的页面中应用标题,而不是在所有内部页面标题中应用标题 page.setExtraHTTPHeaders({ 'X-Just-Must-Be-Req
有没有什么方法可以用 Puppet 的语言声明数组中的包应该按照它们在数组中给出的顺序安装? 我想自动安装 CUDA,这需要 nvidia-driver-latest-dkms、cuda 和 cuda
鉴于这个简化的 Puppet 示例,很明显,由于 ~> 链接运算符,对 my_file 的任何更改都会触发 my_service 刷新: package { 'my_package': } -> fi
我是第一次使用 puppeteer,而不是工程师/程序员! 我已经能够生成我尝试使用 puppeteer 的大部分表单,但是我被单选按钮卡住了。网络表单中的开发人员工具显示该字段的以下内容: 使用:
如果您为代理在后台运行时执行 puppet agent -t,我们可以在其中看到更改的日志文件在哪里,而不是在 puppet 仪表板上。 我查看了 puppet.conf 并在主要部分看到了 logd
我正在尝试使用 exec 资源类型来执行批处理文件。但我想将变量 $dsn_64bit 的值从 init.pp 传递到 install.pp。请让我知道如何实现: 这是我的 init.pp class
我正在尝试使用 list 将用户分配到多个组,但遇到了障碍。 尝试 1: class usergroup { group { "user_one": ensure => present
我想先说我是 puppet 的新手。我一直在通过 vagrant 使用它并且我开始对写作表现感到自在,但我可能缺乏可以回答我的问题的经验或直觉。 我试图掌握 puppet 的范围以及画线的位置。我对这
我是一名优秀的程序员,十分优秀!