1

我正在使用Apify Phanton 爬虫。在 PageFunction 内部我想访问 Apify SDK,您可以使用其他Apify Cheerio-scraperApify puppeteer-scraper 来完成

我注意到 PhantonJS 爬虫上下文确实公开了 Apify 对象,而其他对象则公开了。

一种可能的解决方案是在 pageFunction 中注入 jquery并使用Apify web API

4

1 回答 1

1

phantom 或 Web Scraper 不会公开Apify变量,因为 pageFunction 在浏览器上下文中运行并且 SDK 存在于 Node.js(服务器)上下文中。您可以将我们的 API 与fetch或一起使用JQuery.ajax。只需勾选,disableWebSecurity这样您就可以摆脱 CORS 问题。

于 2020-01-03T13:34:45.700 回答