diff --git a/linkedIn_easy_applier.py b/linkedIn_easy_applier.py index ae60432..2160f6a 100644 --- a/linkedIn_easy_applier.py +++ b/linkedIn_easy_applier.py @@ -253,9 +253,12 @@ class LinkedInEasyApplier: return True return False - def _is_numeric_field(self, element: WebElement) -> bool: - input_type = element.get_attribute('type') - return input_type == 'number' + def _is_numeric_field(self, field: WebElement) -> bool: + field_type = field.get_attribute('type').lower() + if 'numeric' in field_type: + return True + class_attribute = field.get_attribute("id") + return class_attribute and 'numeric' in class_attribute def _enter_text(self, element: WebElement, text: str) -> None: element.clear() diff --git a/linkedIn_job_manager.py b/linkedIn_job_manager.py index bb36f7f..b25bae0 100644 --- a/linkedIn_job_manager.py +++ b/linkedIn_job_manager.py @@ -115,37 +115,34 @@ class LinkedInJobManager: def apply_jobs(self): try: - try: - no_jobs_element = self.driver.find_element(By.CLASS_NAME, 'jobs-search-two-pane__no-results-banner--expand') - if 'No matching jobs found' in no_jobs_element.text or 'unfortunately, things aren' in self.driver.page_source.lower(): - raise Exception("No more jobs on this page") - except NoSuchElementException: - pass - - job_results = self.driver.find_element(By.CLASS_NAME, "jobs-search-results-list") - utils.scroll_slow(self.driver, job_results) - utils.scroll_slow(self.driver, job_results, step=300, reverse=True) - job_list_elements = self.driver.find_elements(By.CLASS_NAME, 'scaffold-layout__list-container')[0].find_elements(By.CLASS_NAME, 'jobs-search-results__list-item') - if not job_list_elements: - raise Exception("No job class elements found on page") - job_list = [Job(*self.extract_job_information_from_tile(job_element)) for job_element in job_list_elements] - for job in job_list: - if self.is_blacklisted(job.title, job.company, job.link): - utils.printyellow(f"Blacklisted {job.title} at {job.company}, skipping...") - self.write_to_file(job, "skipped") - continue - try: - if job.apply_method not in {"Continue", "Applied", "Apply"}: - self.easy_applier_component.job_apply(job) - self.write_to_file(job, "success") - except Exception as e: - utils.printred(traceback.format_exc()) - self.write_to_file(job, "failed") - continue + no_jobs_element = self.driver.find_element(By.CLASS_NAME, 'jobs-search-two-pane__no-results-banner--expand') + if 'No matching jobs found' in no_jobs_element.text or 'unfortunately, things aren' in self.driver.page_source.lower(): + raise Exception("No more jobs on this page") + except NoSuchElementException: + pass - except Exception as e: - traceback.format_exc() - raise e + job_results = self.driver.find_element(By.CLASS_NAME, "jobs-search-results-list") + utils.scroll_slow(self.driver, job_results) + utils.scroll_slow(self.driver, job_results, step=300, reverse=True) + job_list_elements = self.driver.find_elements(By.CLASS_NAME, 'scaffold-layout__list-container')[0].find_elements(By.CLASS_NAME, 'jobs-search-results__list-item') + if not job_list_elements: + raise Exception("No job class elements found on page") + job_list = [Job(*self.extract_job_information_from_tile(job_element)) for job_element in job_list_elements] + for job in job_list: + if self.is_blacklisted(job.title, job.company, job.link): + utils.printyellow(f"Blacklisted {job.title} at {job.company}, skipping...") + self.write_to_file(job, "skipped") + continue + try: + if job.apply_method not in {"Continue", "Applied", "Apply"}: + self.easy_applier_component.job_apply(job) + self.write_to_file(job, "success") + except Exception as e: + utils.printred(traceback.format_exc()) + self.write_to_file(job, "failed") + continue + + def write_to_file(self, job, file_name): data = { @@ -156,6 +153,7 @@ class LinkedInJobManager: "pdf_path": job.pdf_path } file_path = self.output_file_directory / f"{file_name}.json" + file_path = file_path.as_posix() if not file_path.exists(): with open(file_path, 'w', encoding='utf-8') as f: json.dump([data], f, indent=4)