我正在尝试从python运行下面的脚本。
import execjs
var request = require('request');
var apiHostName='https:/url.com';
emailAddress = 'my.email@company.com'
apiKey = 'api_key'
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
console.log("Identity with email address " + emailAddress + " found:");
var b= JSON.parse(body);
console.log("id="+b.identityId+",api key="+b.apiKey+",type="+b.type);
} else{
if (response.statusCode == 401) {
console.log ("Couldn't recognize api key="+apiKey);
} else if (response.statusCode == 403) {
console.log ("Operation forbidden for api key="+apiKey);
} else if (response.statusCode == 404) {
console.log ("Email address " +emailAddress + " not found");
}
}
}
我做到了:
pip install py-mini-racer
pip install PyExecJS
根据我做的研究,我认为这是非常接近的,但我不确定。我现在得到的只是这个错误:'
语法错误:无效语法'
此行出现错误:“var request=require('request');”
显然,我正在使用我的实际电子邮件和API密钥。我正在运行python 3.x。任何帮助都会受到感激。