Answer the question
In order to leave comments, you need to log in
How to execute exec command from platformjs?
I am writing a program on phantomjs, after working out the phantomjs script, it is necessary to save the received information.
Initially, in the script that launches phantomjs, I tried to call mysql and save the data to a table, I run it like this:
phantomjs goview.js
then I call the save function in the goview.js logic:
this is a separate fn.js file
var mysql = require('mysql');
module.exports.saveTasks2 = function(module, tasks){
var connection = mysql.createConnection({
host : '127.0.0.1',
user : 'root',
password : '',
database : 'phantom_muse'
});
var insert = {name_modele_parse: module, json_task: JSON.stringify(tasks)}
var query = connection.query('INSERT INTO tasks SET ?', insert, function(err, result) {
console.log(err);
console.log(result);
if(err===null){
console.log("OUT>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
console.log(tasks)
connection.end();
return true;
}
else
{
console.log('error save')
connection.end();
return false;
}
});
}
Error: Cannot find module 'crypto'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
phantomjs://platform/Connection.js:2
Error: Cannot find module 'url'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
phantomjs://platform/ConnectionConfig.js:2
TypeError: Object is not a constructor (evaluating 'new ConnectionConfig(config)')
phantomjs://platform/index.js:14 in createConnection
phantomjs://platform/api.js:8 in saveTasks2
phantomjs://platform/pagin.parsero.js:29 in parse
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question