0

I've loaded the project to the Apify cloud and as I run it with input, the problem is so funny: No input found!. It works smooth at my PC though.

Run log:

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)

Input:

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

The code has a decent way to call for the INPUT:

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

The log shows the input variable is null...

Can you explain why?

4

1 回答 1

2

在云中,默认存储不命名为“默认”(这基本上只是本地运行中的虚拟名称)。要打开默认商店,您应该简单地调用openKeyValueStore不带任何参数的:

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

这也适用于本地。

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

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

或首选输入:

const input = await Apify.getInput();

所有这些都在 SDK的文档教程中记录和解释。

于 2019-08-20T14:00:14.213 回答