M
M
Mikhailo Poberezhny2016-06-23 21:10:24
Node.js
Mikhailo Poberezhny, 2016-06-23 21:10:24

Why isn't phantom working?

var phantom = require('phantom');
var express = require('express');
var config = require('./config/conf.js');
var http = require('http');
var app = express();
//var page = phantom.create();
var server = http.createServer(app);

app.get('/page', function (req, res) {
    phantom.create().then(function (ph) {
        ph.createPage().then(function (page) {
            page.open('http://dev.myco.network').then(function (status) {
                console.log(status);
                page.injectJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function() {
                    console.log($('body').html());
                    res.json({'pageStatus': status});
                    ph.exit();
                });
            });
        });
    });
});

server.listen(config.port, function() {
    console.log('Server listening on port ' + config.port);
});

does not enter this piece of code, tell me why
page.injectJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function() {
                    console.log($('body').html());
                    res.json({'pageStatus': status});
                    ph.exit();
                });

those. just doesn't render html

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question