It is legal to scrape emails if that information is already publicly available. If you’re scraping a website, you should check that website’s Terms of Use before proceeding. This scraping is illegal if you do it without the website owner’s permission or against their Terms of Service.