【问题标题】:How to find the completion status of apify task run如何查看apify任务运行的完成状态
【发布时间】:2020-01-03 01:11:19
【问题描述】:

如何查找 apify 任务运行的完成状态(成功、失败或中止)?

const crawler = new PhantomCrawler({
        input,
        requestQueue,
        dataset,
    });

    await crawler.run();

或者如果你有

"actorId": ${JSON.stringify(process.env.APIFY_ACTOR_ID || null)},
"taskId": ${JSON.stringify(process.env.APIFY_ACTOR_TASK_ID || null)},
"runId": ${JSON.stringify(process.env.APIFY_ACTOR_RUN_ID || null)},

我在 SDK 或 API 中看不到任何参考

https://sdk.apify.com/docs/api/apify

https://docs.apify.com/api/v2#/reference/actors/actor-object/run-task

【问题讨论】:

    标签: apify


    【解决方案1】:

    每次运行(参与者或任务)都有其 status,如果您将 API 调用发送到 GET run 端点,您可以获得它。当你调用一个演员或任务时,你会得到这个运行信息及其状态。

    里面的代码不需要知道自己的状态,因为如果代码可以请求它,那么任务或参与者当然处于“RUNNING”状态。

    【讨论】:

    • 我用的是js api,但是需要两个参数。 web api 只需要一个。 const run = await Apify.client.acts.getRun({ actId: process.env.APIFY_ACTOR_ID, runId: process.env.APIFY_ACTOR_RUN_ID });
    • 再次,我不确定您需要在哪种情况下检查状态。我写了一篇关于如何使用 API 的文章,也许它会涵盖您的用例 - help.apify.com/en/articles/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-16
    • 2019-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多