1. Achieve web browser automation with Selenium.
2. Log into LinkedIn.com with email and password and start crawling connection information.
--------------------------------------------------------------------------------------------------------------------------------------------------
Special libraries required:
Selenium
BeautifulSoup
To use selenium.webdriver.Chrome() , Chrome driver needs to be put in the directory.
Download link: http://chromedriver.storage.googleapis.com/index.html
Other popular browsers are also available.
--------------------------------------------------------------------------------------------------------------------------------------------------
Code samples:
Set up automated Chrome browser:
browser = webdriver.Chrome()
Open LinkedIn login page:
browser.get("https://linkedin.com/uas/login")
(Sometimes sleep time might be required before using browser.get().
time.sleep(random.uniform(3.5, 6.9))
Randomness is recommended.)
Get the id of password box and fill in the password. Submit at the end.
passElement = browser.find_element_by_id("session_password-login")
passElement.send_keys(password)
passElement.submit()
It is recommended to clear the element input first before send the keys using:
element.clear()
Close the browser at the end of use:
browser.close()
--------------------------------------------------------------------------------------------------------------------------------------------------
Result:
All targets are reached.