这是我执行网页抓取的app.js:
var fs = require('fs');
var path=require('path');
const express = require('express');
var phantomjs = require('phantomjs')
const phantom = require('phantom');
server.post("/" ,async (req,res) =>{
const instance = await phantom.create();
const page = await instance.createPage();
await page.open('mytestwebsite.com', function(status) {
data = page.evaluate(function(){
a = document.getElementsByClassName("class1").innerText;
b = document.getElementsByClassName("class2").innerText;
return data= {
a,
b,
}
});
console.log(data);
instance.exit();
});
});
info: SyntaxError: Unexpected token ','
info: undefined:7 in Function
info: phantomjs://code/index.js:315
info: :0 in parse
info: phantomjs://code/index.js:307 in read