- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是Nightmare js的新手,并试图从网站上抓取一些数据。但是后来我遇到了这个错误,我无法理解我可能做错了什么。有人可以向我解释什么问题吗?
我要抓取的元素如下。我正在尝试提取标记之间的文本,如下所示<span class="home__matches__match__header__game-id">Game ID 9490 - </span> Kenya - Premier League
<div class="home__sports">
<div class="home__sports__title">
<div class="home__sports__title__category">Kenya - Premier League</div>
<div class="home__sports__title__copy">
<span title="Copy" class="icon home__sports__title__copy__icon icon__copy has-tooltip">
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" viewBox="0 0 488.244 488.244" xml:space="preserve" width="15px">
<g>
<g>
<g>
<path d="M284.141,138.477V72.896H43.678v415.348h306.045V138.477H284.141z" fill="#FFFFFF"></path>
<polygon points="290.682,72.723 290.682,131.247 349.205,131.247 " fill="#FFFFFF"></polygon>
</g>
<g>
<polygon points="385.525,0 385.525,58.524 444.048,58.524 " fill="#FFFFFF"></polygon>
<polygon points="378.985,65.753 378.985,0.172 138.521,0.172 138.521,65.581 291.543,65.581 357.124,131.162 357.124,415.519 444.566,415.519 444.566,65.753 " fill="#FFFFFF"></polygon>
</g>
</g>
</g>
</svg>
</span>
<span>Copy</span>
</div>
</div>
<div class="home__sports__matches scrollable" tabindex="0">
<!---->
<!---->
<!---->
<!---->
<!---->
<div class="home__matches__match">
<div class="home__matches__match__header clearfix">
<span class="home__matches__match__header__game-id">Game ID 9490 - </span> Kenya - Premier League
<span class="pull-right">13/06, 15:00</span>
</div>
<div class="home__matches__match__odds">
<button class="home__matches__match__odds__odd bold clearfix">
Wazito
<span class="pull-right bold">8.84</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
X
<span class="pull-right bold">4.67</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
GOR Mahia FC
<span class="pull-right bold">1.41</span>
</button>
<button class="home__matches__match__odds__markets clearfix bold">
+25
</button>
</div>
<!---->
</div>
<div class="home__matches__match">
<div class="home__matches__match__header clearfix">
<span class="home__matches__match__header__game-id">Game ID 3924 - </span> Kenya - Premier League
<span class="pull-right">13/06, 15:00</span>
</div>
<div class="home__matches__match__odds">
<button class="home__matches__match__odds__odd bold clearfix">
Kariobangi Sharks
<span class="pull-right bold">2.61</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
X
<span class="pull-right bold">3.05</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
Nzoia United
<span class="pull-right bold">2.93</span>
</button>
<button class="home__matches__match__odds__markets clearfix bold">
+25
</button>
</div>
<!---->
</div>
<div class="home__matches__match">
<div class="home__matches__match__header clearfix">
<span class="home__matches__match__header__game-id">Game ID 8769 - </span> Kenya - Premier League
<span class="pull-right">13/06, 15:00</span>
</div>
<div class="home__matches__match__odds">
<button class="home__matches__match__odds__odd bold clearfix">
Ulinzi Stars FC
<span class="pull-right bold">2.3</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
X
<span class="pull-right bold">3.05</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
Kakamega Homeboyz
<span class="pull-right bold">4.2</span>
</button>
<button class="home__matches__match__odds__markets clearfix bold">
+25
</button>
</div>
<!---->
</div>
<div class="home__matches__match">
<div class="home__matches__match__header clearfix">
<span class="home__matches__match__header__game-id">Game ID 3021 - </span> Kenya - Premier League
<span class="pull-right">13/06, 15:00</span>
</div>
<div class="home__matches__match__odds">
<button class="home__matches__match__odds__odd bold clearfix">
AFC Leopards SC
<span class="pull-right bold">2.66</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
X
<span class="pull-right bold">3.21</span>
</button>
<button class="home__matches__match__odds__odd bold clearfix">
Sofapaka FC
<span class="pull-right bold">2.61</span>
</button>
<button class="home__matches__match__odds__markets clearfix bold">
+25
</button>
</div>
<!---->
</div>
</div>
<!---->
</div>
var jquery = require('jquery');
var Nightmare = require('nightmare');
var express = require('express');
nightmare = Nightmare()
var app = express();
nightmare.goto('https://www.betika.com/competition/701')
.wait(2000)
.evaluate(function () {
var gameids=[]
var res;
var gameids=[]
$('.home__matches__match__header__game-id').each(function(){
console.log('Entered')
item ={}
item['gameid'] = $(this).text()
gameids.push(item);
})
return {
res:gameids
};
},function (value) {
/*for (gameids in value){
console.log(value[gameids.gameid])
}*/
console.log("gotcha",value)
}
)
.run(function (err, nightmare) {
if (err) return console.log(err);
});
{ Error: navigation error
at unserializeError (/home/surajit/WebstormProjects/Odds/node_modules/nightmare/lib/ipc.js:162:13)
at EventEmitter.<anonymous> (/home/surajit/WebstormProjects/Odds/node_modules/nightmare/lib/ipc.js:89:13)
at Object.onceWrapper (events.js:312:19)
at emitTwo (events.js:125:13)
at EventEmitter.emit (events.js:213:7)
at ChildProcess.<anonymous> (/home/surajit/WebstormProjects/Odds/node_modules/nightmare/lib/ipc.js:49:10)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at process.nextTick (internal/child_process.js:755:12)
at _combinedTickCallback (internal/process/next_tick.js:95:7)
code: -7,
details: 'Navigation timed out after 30000 ms',
url: 'https://www.betika.com/competition/701' }
最佳答案
甚至在我的普通浏览器上,似乎网站或数据都需要花费很多时间才能加载,已经差不多2分钟了,但仍然没有加载。 Nightmare 中设置的导航超时时间为30秒。
然后,如果URL无效,它将永远不会加载。因此,我点击了有效的竞争网址,并最终加载了该网址。
这与您的代码无关,与您处理或提供目标网站的方式有关。
关于node.js - Nightmare js出现错误的导航错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50836518/
好吧,我用 Nightmare 来做一些测试任务,对于基于电子和phatomjs的代码来说是如此的好。 现在,我有一个问题,我该如何通过 Nightmare 上传图像文件? 好吧,我找到了一个名为ni
我找不到这方面的任何信息,主要是因为一旦我在同一句话上输入带有“Nightmare ”和“IE”的google搜索,您就会知道... 有没有办法像在IE兼容模式下一样运行nightmare.js? 最
我试图从网站中提取数据,我想在 10 分钟后循环查看数据是否已更改。我认为将我的功能打包在模块中是一个好主意,但现在我坚持将我当前的 Nightmare 实例从登录模块转移到数据模块。 开始.js v
我很难过要在Travis CI上运行它。它会间歇性地工作,但 Nightmare 通常会因以下错误而失败: nightmare:log did-get-response-details [{},f
使用nightmarejs如何在文件输入中输入文件并进行确认? 它用于附件的自动化(例如电子邮件)。我的意思是输入文件是这样的: 最佳答案 我所知道的使用Nightmare进行上传的唯一方法是使用de
我想抓取并通过页面中的每个herf获取html,然后输出到csv。现在我第一次使用 Nightmare 。所以我对未定义的段落有疑问。 var Nightmare = require('nightma
var Nightmare = require('nightmare'); var nightmare = Nightmare({ show: true }); var fs = require('
我目前正在开发一个程序来自动化某个网站上的任务(简化代码如下)。我很好地登录,然后等待页面加载,但是wait函数永远不会结束。我尝试使用wait(200),但是评估函数返回一个空数组。我100%确信网
我尝试在F12时单击包含这些详细信息的按钮 Show all results for 'lundhags' 我已经复制了xpath并且有这样的代码=>I.click('//*[@id="9"]');
我在javascript中使用Nightmare创建网络抓取工具,但是评估功能未返回正确的信息。似乎它能够返回原始类型(int,字符串等),但不能返回“querySelectorAll”中的元素列表。
我正在尝试NightmareJS进行一些我想完成的自动化操作。我遇到的一个问题是, Nightmare/Electron 无法解析adidas网站,但是它可以解析并访问任何其他网页。 This is
我想使用 Nightmare JS 通过检查状态代码 200 来确定页面是否正在加载。我查看了 goto 选项,但无法弄清楚。大家有什么想法吗? var Nightmare = require('ni
我刚刚开始使用 Nightmare 。我在我的网页上使用它用于测试目的。 我有以下用户界面。 menu tab1 | tab2 | tab3 ......(dynamically generated
如何使用 nightmare-iframe 插件访问具有随机生成名称的 iframe? 我试过了 var name = yield nightmare .goto(defaultUrl) .c
如何在服务器上通过pm2或类似的东西运行nightmarejs,因为 Nightmare 使用电子,而电子现在需要图形,我正在使用xvfb-run npm start ,但是这个 sol° 需要我通过
下面的代码片段是来自 https://github.com/segmentio/nightmare 的示例 const Nightmare = require('nightmare') const n
我知道在任何环境中处理日期都可能会非常令人困惑,但我正处于一场噩梦中,这个函数本应该是一项微不足道的工作。我想以不同的方式操作某些日期,但出现错误或错误的结果。 下面我将报告一个非常简单的例子来测试执
我有以下代码: for(var i = 0; i { return true; }) } 我正在 Electron 应用程序中使用它。然而,这会执行异步,我会立
我正在尝试使用 github.com/segmentio/nightmare 自动化 2 个站点 例子: 我想继续访问 site_1(临时电子邮件服务)并获得电子邮件。 然后转到 site_2 并填写
我正在尝试使用 Nightmare 抓取网页,但想等待 #someelem 出现,前提是它确实存在。否则,我希望 Nightmare 继续前进。如何使用 .wait() 完成此操作? 我不能使用 .w
我是一名优秀的程序员,十分优秀!