Apify and Crawlee Official Forum

Updated 3 months ago

Function not executing for a reason.

Plain Text
async def main():


    async with Actor:
        input_data = await Actor.get_input() 
        urls = input_data['websites']
        print(urls)




    async with aiohttp.ClientSession() as session:
        tasks = [fetch_emails(session, website) for website in urls]
        results = await asyncio.gather(*tasks)
        print('here')
    dataset = apify_client.dataset()
    for email in website_list:
        print(email)
        dataset.push_data({"email": email})

    print(website_list)
    print(f"tried to scrape {len(urls)}")
    print(f"there is {invalid_url}")
    print(f'successfully scraped {len(website_list)} emails ! ')

asyncio.run(main())
the
Plain Text
async with Actor:
        input_data = await Actor.get_input() 
        urls = input_data['websites']
        print(urls)
does print the url. But after that, the code stops. The scripts work fine in vsc. I'm trying to integrate it with apify but I'm facing some issues.
R
K
A
3 comments
hey, try to put the whole code in the Actor context manager: (under async with Actor:). You can read more about Actor lifecycles and alternatives here: https://docs.apify.com/sdk/python/docs/concepts/actor-lifecycle
Already figured that out but ty anyways
just advanced to level 2! Thanks for your contributions! πŸŽ‰
Add a reply
Sign up and join the conversation on Discord