Apify 云中没有获取任何“输入”

No `input` is fetched in the Apify cloud

我已经将项目加载到 Apify 云中,当我 运行 它输入时,问题很有趣:没有 input 找到!.不过,它在我的电脑上运行流畅。

运行 日志:

2019-08-20T13:17:57.313Z ACTOR: Creating Docker container.
2019-08-20T13:17:58.013Z ACTOR: Starting Docker container.
2019-08-20T13:17:59.614Z INFO: System info {"apifyVersion":"0.13.7","apifyClientVersion":"0.5.14","osType":"Linux","nodeVersion":"v10.16.0"}
2019-08-20T13:18:00.081Z input: null
2019-08-20T13:18:00.083Z The function passed to Apify.main() threw an exception:
2019-08-20T13:18:00.085Z TypeError: Cannot read property 'concurrency' of null
2019-08-20T13:18:00.086Z     at Apify.main (/home/myuser/main.js:71:36) 
2019-08-20T13:18:00.087Z     at process._tickCallback (internal/process/next_tick.js:68:7)

输入:

{   
"page_handle_max_wait_time" : 2,
"concurrency" : 6,
"max_requests_per_crawl" : 10000, 
"retireInstanceAfterRequestCount": 5000,
...
}

代码有一个不错的方式来调用输入:

const store = await Apify.openKeyValueStore('default'); 
const input = await store.getValue('INPUT'); 
console.log('input:', input);

日志显示 input 变量是 null...

你能解释一下为什么吗?

在云中,默认商店未命名为 "default"(这基本上只是本地运行中的虚拟名称)。要打开默认商店,您只需调用不带任何参数的 openKeyValueStore

const store = await Apify.openKeyValueStore();
const input = await store.getValue('INPUT'); 

这在本地也适用。

默认存储中的记录有一个较短的版本:

const input = await Apify.getValue('INPUT'); 

或首选输入:

const input = await Apify.getInput();

SDK 的 Docs and tutorials 中记录并解释了所有这些内容。