Created
September 1, 2016 02:26
-
-
Save tianhengzhou/1a7176a8a5133e111ab23f02ae8cf8c6 to your computer and use it in GitHub Desktop.
A script use to add recruiter on LinkedIn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from selenium import webdriver | |
# from urlparse import urlparse | |
# from urlparse import parse_qs | |
from selenium.webdriver.support.ui import WebDriverWait | |
# from selenium.common.exceptions import NoSuchElementException | |
# from selenium.webdriver.common.action_chains import ActionChains | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.by import By | |
# from selenium.webdriver.common.keys import Keys | |
# from selenium.webdriver.common.alert import Alert | |
# from selenium.webdriver.support.ui import Select | |
# import re | |
# from retrying import retry | |
class Modules: | |
def __init__(self): | |
self.driver = webdriver.Chrome('/Users/tianhengzhou/Downloads/chromedriver') | |
def url_generator(self, keywords): | |
url_prefix = 'https://www.linkedin.com/vsearch/' | |
url_complete = url_prefix + 'f?type=all&keywords=' | |
k_array = keywords.split(' ') | |
for i in range(len(k_array)): | |
if i == len(k_array) - 1: | |
url_complete += k_array[i] | |
else: | |
url_complete += k_array[i] + '+' | |
return url_complete | |
def linkedin_search_page_scanning(self, keywords): | |
url = self.url_generator(keywords) | |
self.driver.get(url) | |
xpath_connect_button = "//a[contains(text(),'Connect')]" | |
for i in range(1,101): | |
WebDriverWait(self.driver, 120).until(EC.presence_of_element_located((By.XPATH, xpath_connect_button))) | |
connect_button_list = self.driver.find_elements_by_link_text('Connect') | |
for e in connect_button_list: | |
e.click() | |
time.sleep(5) | |
self.driver.get(url + '&pt=people&page_num=' + str(i)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from module import Modules as module | |
test = module() | |
# test.page_scanning(2) | |
# test.page_scanning(5) | |
# test.page_scanning(22) | |
test.linkedin_search_page_scanning('Front End Recruiter') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment