can you write a full python script that scrapes all skills listed on the linkedin…
- User
can you write a full python script that scrapes all skills listed on the linkedin profiles of any Hinicio employee whose job title contains "analyst"
- Assistant
To create a Python script that scrapes all skills listed on the LinkedIn profiles of Hinicio employees whose job title contains "analyst", you'll need to use a library like
BeautifulSoupfor web scraping andSeleniumfor automating browser actions. First, make sure to install the required libraries:bashpip install beautifulsoup4 selenium webdriver_managerNow, here's a full Python script that accomplishes the task. Please note that web scraping LinkedIn is against their terms of service, and this script is for educational purposes only. Always respect the website's
robots.txtrules and terms of service.pythonimport time from bs4 import BeautifulSoup from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC # Set up the Selenium webdriver options = webdriver.ChromeOptions() options.add_argument("--headless") # Run browser in background options.add_argument("--no-sandbox") driver = webdriver.Chrome(ChromeDriverManager().install(), options=options) # LinkedIn search URL for Hinicio employees with "analyst" in their job title base_url = "https://www.linkedin.com/search/results/people/?keywords=analyst&location=Hinicio&title=analyst" def get_employee_profiles(url): driver.get(url) time.sleep(5) # Wait for the page to load while True: # Scroll down to load more results driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") time.sleep(2) # Check if there are more results to load try: WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "button[aria-label='See more']"))) except Exception: break soup = BeautifulSoup(driver.page_source, "html.parser") profiles = soup.find_all("li", class_="artdeco-list__item p0") return [profile.find("a", class_="app-aware-link")["href"] for profile in profiles] def get_skills(profile_url): driver.get(profile_url) time.sleep(5) # Wait for the page to load soup = BeautifulSoup(driver.page_source, "html.parser") skills = soup.find_all("li", class_="pv-skill-category-entity__skill") return [skill.text.strip() for skill in skills] def main(): employee_profiles = get_employee_profiles(base_url) for profile in employee_profiles: print(f"Scraping skills for profile: {profile}") skills = get_skills(profile) print(f"Skills: {', '.join(skills)}\n") if __name__ == "__main__": main() # Close the browser driver.quit()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.