首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >X射线-幻影认证,无法有效登录

X射线-幻影认证,无法有效登录
EN

Stack Overflow用户
提问于 2015-10-22 19:29:46
回答 1查看 654关注 0票数 11

我真的找不到任何使用x射线和.driver(幻影())进行身份验证的例子。我已经翻阅了x射线和x射线幻影的文档,但却找不到任何帮助。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-28 09:23:21

代码语言:javascript
运行
复制
/**
 * Module Dependencies
 */

var Crawler = require('x-ray-crawler');
var cheerio = require('cheerio');
var join = require('path').join;
var assert = require('assert');
var phantom = require('../');
var fs = require('fs');

/**
 * Tests
 */

describe('phantom driver', function() {

  it('should have sensible defaults', function(done) {
    var crawler = Crawler()
      .driver(phantom())

    crawler('http://google.com', function(err, ctx) {
      if (err) return done(err);
      var $ = cheerio.load(ctx.body);
      var title = $('title').text();
      assert.equal('Google', title);
      done();
    })
  });

  it('should work with client-side pages', function(done) {
    var crawler = Crawler()
      .driver(phantom());

    crawler('https://exchange.coinbase.com/trade', function(err, ctx) {
      if (err) return done(err);
      var $ = cheerio.load(ctx.body);
      var price = $('.market-num').text();
      assert.equal(false, isNaN(+price));
      done();
    })
  })

  it('should support custom functions', function(done) {
    var crawler = Crawler()
      .driver(phantom(runner));

    crawler('http://mat.io', function(err, ctx) {
      if (err) return done(err);
      var $ = cheerio.load(ctx.body);
      var title = $('title').text();
      assert.equal('Lapwing Labs', title);
      done();
    })

    function runner(ctx, nightmare) {
      return nightmare
        .goto(ctx.url)
        .click('.Header-logo-item+ .Header-list-item a')
        .wait()
    }
  })
})

/**
 * Read
 */

function get(path) {
  return require(join(__dirname, 'fixtures', path));
}

如果有帮助,请参考下面的github链接。

  1. https://github.com/lapwinglabs/x-ray-phantom
  2. https://github.com/lapwinglabs/x-ray/issues/22
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33289143

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档