【问题标题】:Accessing web page with CasperJS [duplicate]使用 CasperJS 访问网页 [重复]
【发布时间】:2015-08-06 19:56:41
【问题描述】:

我可以访问 Google 以获取页面标题:

var casper = require('casper').create();
casper.start('http://google.com', function() {
    this.echo(this.getTitle());
})
casper.run();
// "Google"

但由于某种原因,我无法访问 iTunes Connect 页面:

var casper = require('casper').create();
casper.start('https://itunesconnect.apple.com', function() {
    this.echo(this.getTitle());
})
// Undefined

如何成功请求上述页面?

这是我目前得到的:

[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[debug] [phantom] opening url: https://itunesconnect.apple.com/, HTTP GET
[debug] [phantom] Navigation requested: url=https://itunesconnect.apple.com/, type=Other, willNavigate=true, isMainFrame=true
[warning] [phantom] Loading resource failed with status=fail: https://itunesconnect.apple.com/
[debug] [phantom] Successfully injected Casper client-side utilities
[object Casper], currently at about:blank
[info] [phantom] Step anonymous 2/2: done in 66ms.
[info] [phantom] Done 2 steps in 86ms

【问题讨论】:

  • 您使用什么版本的 PhantomJS?请注册resource.errorpage.errorremote.messagecasper.page.onResourceTimeout 活动 (Example)。可能有错误。
  • @ArtjomB。我将如何在start() 函数中应用上述内容?

标签: javascript phantomjs casperjs


【解决方案1】:

运行脚本时需要指定ssl:

casperjs --ssl-protocol=tlsv1 script.js

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多