Actor picture

Save Linkedin PIN Code

petr_cermak/save-linkedin-code

No credit card required

Author's avatarPetr Cermak
  • Modified
  • Users3
  • Runs23
Actor picture

Save Linkedin PIN Code

Based on the apify/actor-node-basic Docker image (see docs).

const Apify = require('apify');

Apify.main(async () => {
    let input = null;
    const inputData = await Apify.getInput();
    if(typeof inputData !== 'object'){
        input = {};
        const lines = inputData.split(/\r?\n/g);
        for(let i = 0; i < lines.length; i++){
            const name = lines[i].trim();
            if(name === 'storeName'){input.storeName = lines[i + 1].trim();}
            else if(name === 'storeKey'){input.storeKey = lines[i + 1].trim();}
        }
        const bodyIndex = inputData.indexOf('emailBody');
        input.emailBody = inputData.slice(bodyIndex + 'emailBody'.length).trim();
    }
    else{input = inputData;}

    console.dir(input);

    const store = await Apify.openKeyValueStore(input.storeName);
    
    const value = input.emailBody.match(/sign in\: (\d+)/);
    if(value){await store.setValue(input.storeKey, {code: value[1].trim()});}
    else{throw new Error('Invalid code!');}
});