我想单击 html 页面中的链接,其中包含以下代码段:
<p>Die maximale Trefferanzahl von 200 wurde überschritten.
<a href="/rp_web/search.do?doppelt">Verdoppeln Sie hier Suchergebnislimit.</a>
</p>
Run Code Online (Sandbox Code Playgroud)
我之前设置了一些过滤器,然后我正在加载页面,这将加载我需要的页面。在结果页面上,我想单击 html 代码段中的链接。我正在尝试使用的 js 是这个
await Promise.all([
page.click('input#landNW'), // set a filter
page.click('input[type=submit]'), // submit the form
page.waitForNavigation(), // wait for the page to load
page.click('p a'), // not working: double the search results
page.waitForNavigation() // not working: waiting for the page to reload
]).catch(e => console.log(e)); // no error
Run Code Online (Sandbox Code Playgroud)
我很确定page.click('p a')它工作正常,因为在我的 chrome 浏览器的控制台中我可以做document.querySelector("p a").click(),然后按预期重新加载页面。
我还尝试通过使用 href attr 来选择 url,例如 …
我试图让我的在线机器人无法被检测到。我阅读了许多如何做到这一点的文章,并将所有技巧放在一起并使用它们。其中之一是改变window.navigator.webdriver。
我设法window.navigator.webdriver通过以下代码在 puppeteer 中进行了更改:
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'webdriver', {
get: () => undefined
});
});
Run Code Online (Sandbox Code Playgroud)
我绕过这个测试就好了:
然而,这个测试仍然以某种方式嘲笑我:
为什么WEBDRIVER不一致?
我正在使用Node Webkit作为我的网络应用程序,我真的是使用node webkit的新手.我想在我的应用程序中运行我的exe,但我甚至无法使用'child_process'打开简单的记事本.我在网站上看到了一些例子,但我发现很难运行notepad.exe,请提前帮助并非常感谢.
var execFile = require
('child_process').execFile, child;
child = execFile('C:\Windows\notepad.exe',
function(error,stdout,stderr) {
if (error) {
console.log(error.stack);
console.log('Error code: '+ error.code);
console.log('Signal received: '+
error.signal);
}
console.log('Child Process stdout: '+ stdout);
console.log('Child Process stderr: '+ stderr);
});
child.on('exit', function (code) {
console.log('Child process exited '+
'with exit code '+ code);
});
Run Code Online (Sandbox Code Playgroud)
此外,我试图使用meadco-neptune插件运行exe并添加插件我把代码放在package.json文件中,但它显示无法加载插件.我的package.json文件是这样的
{
"name": "sample",
"version": "1.0.0",
"description": "",
"main": "index.html",
"window": {
"toolbar": false,
"frame": false,
"resizable": false,
"show": true,
"title": " example"
},
"webkit": {
"plugin": true …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用nightmarejs(使用电子作为浏览器的phantomjs派生词)从Instagram个人资料页面中搜索一些信息.
目标是获取配置文件中所有图像的alt标签(例如,我只关注"显示更多"按钮之前的图像)
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });
nightmare
.goto('https://www.instagram.com/ackerfestival/')
.evaluate(function () {
let array = [...document.querySelectorAll('._icyx7')];
return array.length;
})
.end()
.then(function (result) {
console.log(result);
})
.catch(function (error) {
console.error('Search failed:', error);
});
Run Code Online (Sandbox Code Playgroud)
这个例子有效,数组的长度为12.电子浏览器打开和关闭,所以一切都很好.但是,如果我将返回更改为只是数组,电子浏览器永远不会关闭,我没有得到console.log.
我究竟做错了什么?我想从数组或对象中的图像中获取所有信息.
因为我也不知道编程,我知道你可以用不同的方式来做(你可以帮助如何)那么请帮助我,如果我可以以某种方式使用此代码中的字符或(|| 或 &&)?
我希望将多个选择器的结果显示在一行中。
当我这样做时,我得到了结果,但它们分别返回给我 X 和 Y,我想要一个结果:x1 - y1、x2 - y2 等。
const x = await page.$$eval('.classxxx', options => options.map(option => option.textContent));
const y = await page.$$eval('.classsyyyy', options => options.map(option => option.textContent));
console.log(x); // x1, x2, x3
console.log(y); // y1, y2, y3
Run Code Online (Sandbox Code Playgroud)
我希望结果在下一部分中彼此相邻显示
console log(xy); // x1 y1, x2 y2, x3 y3
Run Code Online (Sandbox Code Playgroud)
我一直在考虑类似的事情,但它不起作用:
const y = await page.$$eval('.classsyyyy || .classxxx', options => options.map(option => option.textContent));
Run Code Online (Sandbox Code Playgroud) node.js ×4
javascript ×3
puppeteer ×3
detection ×1
exe ×1
nightmare ×1
node-webkit ×1
selenium ×1
web-scraping ×1
webkit ×1