为什么 "context.Apify" 未定义
Why is "context.Apify" undefined
我正在尝试学习如何在 Apify Web-Scraper Actor 中使用请求,我不明白它是如何工作的。
我第一次用 Postman 做了这个,我确实得到了我想要的结果,现在我想在 Apify 上做同样的事情。
async function pageFunction(context) {...
const request = new context.Apify.Request({
url:...
headers: { Accept: 'application/json' },
method: 'POST',
payload:{...}
})
}
我想获取与此请求对应的 Json 个文件。相反,我得到一个错误:"Cannot read property 'Request' of undefined"
看起来您可能没有通过使用 npm (npm install apify
) 安装它然后使用 const Apify = require('apify');
来导入 Apify 库
"Try It Out"
下的this page底部有例子
context.Apify
仅在 Puppeteer Scraper 中可用,在 Web Scraper 中不可用。 Web Scraper 只是一个简单的浏览器内界面,因此将所有 Apify 功能移植到浏览器中几乎是不可能的。
我正在尝试学习如何在 Apify Web-Scraper Actor 中使用请求,我不明白它是如何工作的。
我第一次用 Postman 做了这个,我确实得到了我想要的结果,现在我想在 Apify 上做同样的事情。
async function pageFunction(context) {...
const request = new context.Apify.Request({
url:...
headers: { Accept: 'application/json' },
method: 'POST',
payload:{...}
})
}
我想获取与此请求对应的 Json 个文件。相反,我得到一个错误:"Cannot read property 'Request' of undefined"
看起来您可能没有通过使用 npm (npm install apify
) 安装它然后使用 const Apify = require('apify');
"Try It Out"
下的this page底部有例子context.Apify
仅在 Puppeteer Scraper 中可用,在 Web Scraper 中不可用。 Web Scraper 只是一个简单的浏览器内界面,因此将所有 Apify 功能移植到浏览器中几乎是不可能的。