Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ def chooseResume(self) -> None:
By.CLASS_NAME, "jobs-document-upload__title--is-required")
resumes = self.driver.find_elements(
By.XPATH, "//div[contains(@class, 'ui-attachment--pdf')]")
if (len(resumes) == 1 and resumes[0].get_attribute("aria-label") == "Select this resume"):
if len(resumes) == 1 and resumes[0].get_attribute("aria-label") == "Select this resume":
resumes[0].click()
elif (len(resumes) > 1 and resumes[config.preferredCv-1].get_attribute("aria-label") == "Select this resume"):
elif len(resumes) > 1 and resumes[config.preferredCv-1].get_attribute("aria-label") == "Select this resume":
resumes[config.preferredCv-1].click()
elif (type(len(resumes)) != int):
elif len(resumes) == 0:
utils.prRed(
"❌ No resume has been selected please add at least one resume to your Linkedin account.")
except Exception:
Expand All @@ -321,22 +321,22 @@ def getJobProperties(self, count: int) -> str:

try:
jobTitle = self.driver.find_element(By.XPATH, "//h1[contains(@class, 'job-title')]").get_attribute("innerHTML").strip()
res = [blItem for blItem in config.blackListTitles if (blItem.lower() in jobTitle.lower())]
if (len(res) > 0):
res = [blItem for blItem in config.blackListTitles if blItem.lower() in jobTitle.lower()]
if len(res) > 0:
jobTitle += "(blacklisted title: " + ' '.join(res) + ")"
except Exception as e:
if (config.displayWarnings):
if config.displayWarnings:
utils.prYellow("⚠️ Warning in getting jobTitle: " + str(e)[0:50])
jobTitle = ""

try:
time.sleep(5)
jobDetail = self.driver.find_element(By.XPATH, "//div[contains(@class, 'job-details-jobs')]//div").text.replace("·", "|")
res = [blItem for blItem in config.blacklistCompanies if (blItem.lower() in jobTitle.lower())]
if (len(res) > 0):
res = [blItem for blItem in config.blacklistCompanies if blItem.lower() in jobTitle.lower()]
if len(res) > 0:
jobDetail += "(blacklisted company: " + ' '.join(res) + ")"
except Exception as e:
if (config.displayWarnings):
if config.displayWarnings:
print(e)
utils.prYellow("⚠️ Warning in getting jobDetail: " + str(e)[0:100])
jobDetail = ""
Expand All @@ -347,7 +347,7 @@ def getJobProperties(self, count: int) -> str:
jobLocation = jobLocation + " | " + span.text

except Exception as e:
if (config.displayWarnings):
if config.displayWarnings:
print(e)
utils.prYellow("⚠️ Warning in getting jobLocation: " + str(e)[0:100])
jobLocation = ""
Expand Down
11 changes: 6 additions & 5 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def chromeBrowserOptions():
options.add_argument("--disable-extensions")
options.add_argument('--disable-gpu')
options.add_argument('--disable-dev-shm-usage')
if(config.headless):
if config.headless:
options.add_argument("--headless")
options.add_argument("--start-maximized")
options.add_argument("--disable-blink-features")
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_experimental_option('useAutomationExtension', False)
options.add_experimental_option("excludeSwitches", ["enable-automation"])
if(len(config.chromeProfilePath)>0):
if len(config.chromeProfilePath) > 0:
# Handle both Windows (\) and Unix (/) path separators
# Normalize path separators to handle mixed separators
normalized_path = config.chromeProfilePath.replace('\\', os.sep).replace('/', os.sep)
Expand Down Expand Up @@ -75,12 +75,13 @@ def getUrlDataFile() -> List[str]:
def jobsToPages(numOfJobs: str) -> int:
number_of_pages = 1

if (' ' in numOfJobs):
if ' ' in numOfJobs:
spaceIndex = numOfJobs.index(' ')
totalJobs = (numOfJobs[0:spaceIndex])
totalJobs = numOfJobs[0:spaceIndex]
totalJobs_int = int(totalJobs.replace(',', ''))
number_of_pages = math.ceil(totalJobs_int/constants.jobsPerPage)
if (number_of_pages > 40 ): number_of_pages = 40
if number_of_pages > 40:
number_of_pages = 40

else:
number_of_pages = int(numOfJobs)
Expand Down