Yes, it is legal as long as you target public data, comply with robots.txt for web scraping, and abide by LinkedIn's Terms and Conditions.