Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Apify.main(async () => {
// Launch the web browser.
const browser = await Apify.launchPuppeteer();
console.log('Obtaining email address...');
const user = await Apify.client.users.getUser();
// Load Kraken.com charts and get last traded price of BTC
console.log('Extracting data from kraken.com...');
const page = await browser.newPage();
await page.goto('https://www.kraken.com/charts');
const tradedPricesHtml = await page.$eval('#ticker-top ul', el => el.outerHTML);
// Send prices to your email. For that, you can use an actor we already
// have available on the platform under the name: apify/send-mail.
// The second parameter to the Apify.call() invocation is the actor's
// desired input. You can find the required input parameters by checking
// the actor's documentation page: https://apify.com/apify/send-mail
console.log(`Sending email to ${user.email}...`);
await Apify.call('apify/send-mail', {
to: user.email,
subject: 'Kraken.com BTC',
const fetchInput = async () => {
const input = await Apify.getValue('INPUT');
const crawler = input.crawlerId
? await Apify.client.crawlers.getCrawlerSettings({ crawlerId: input.crawlerId })
: {};
// NOTE: In old crawler settings can be some values null, replace them with default values
deleteNullProperties(crawler);
deleteNullProperties(input);
const mergedInput = _.defaults(input, crawler, INPUT_DEFAULTS, {
actId: APIFY_ACT_ID,
runId: APIFY_ACT_RUN_ID,
});
mergedInput.crawlPurls = mergedInput.crawlPurls || [];
mergedInput.crawlPurls.forEach((purl) => {
purl.parsedPurl = new PseudoUrl(purl.value);
});
const fetchInput = async () => {
const input = await Apify.getValue('INPUT');
if (!input.crawlerId) return input;
const crawler = await Apify.client.crawlers.getCrawlerSettings({ crawlerId: input.crawlerId });
return Object.assign({}, input, crawler);
};