geenral fix

This commit is contained in:
feder-cr 2024-08-05 01:09:50 +01:00
parent fddfe5bb9c
commit 8a042217cb
4 changed files with 44 additions and 20 deletions

2
gpt.py
View File

@ -224,7 +224,7 @@ class GPTAnswerer:
}
section_prompt = (
f"For the following question: '{question}', which section of the resume is relevant? "
"Respond with one of the following: Personal information, Self-Identification, Legal Authorization, "
"Respond with one of the following: Personal information, Self Identification, Legal Authorization, "
"Work Preferences, Education Details, Experience Details, Projects, Availability, Salary Expectations, "
"Certifications, Languages, Interests."
)

View File

@ -94,19 +94,24 @@ class LinkedInEasyApplier:
def _fill_application_form(self):
while True:
self.fill_up()
self._next_or_submit()
if self._next_or_submit():
break
def _next_or_submit(self):
next_button = self.driver.find_element(By.CLASS_NAME, "artdeco-button--primary")
button_text = next_button.text.lower()
if 'submit application' in button_text:
self._unfollow_company()
next_button.click()
return True
time.sleep(random.uniform(1.5, 2.5))
next_button.click()
time.sleep(random.uniform(3.0, 5.0))
self._check_for_errors()
def _unfollow_company(self) -> None:
try:
follow_checkbox = self.driver.find_element(
@ -130,10 +135,14 @@ class LinkedInEasyApplier:
pass
def fill_up(self) -> None:
easy_apply_content = self.driver.find_element(By.CLASS_NAME, 'jobs-easy-apply-content')
pb4_elements = easy_apply_content.find_elements(By.CLASS_NAME, 'pb4')
for element in pb4_elements:
self._process_form_element(element)
try:
easy_apply_content = self.driver.find_element(By.CLASS_NAME, 'jobs-easy-apply-content')
pb4_elements = easy_apply_content.find_elements(By.CLASS_NAME, 'pb4')
for element in pb4_elements:
self._process_form_element(element)
except Exception as e:
pass
def _process_form_element(self, element: WebElement) -> None:

View File

@ -80,41 +80,41 @@ class LinkedInJobManager:
for position, location in searches:
location_url = "&location=" + location
job_page_number = -1
print(f"Starting the search for {position} in {location}.")
utils.printyellow(f"Starting the search for {position} in {location}.")
try:
while True:
page_sleep += 1
job_page_number += 1
print(f"Going to job page {job_page_number}")
utils.printyellow(f"Going to job page {job_page_number}")
self.next_job_page(position, location_url, job_page_number)
time.sleep(random.uniform(1.5, 3.5))
print("Starting the application process for this page...")
utils.printyellow("Starting the application process for this page...")
self.apply_jobs()
print("Applying to jobs on this page has been completed!")
utils.printyellow("Applying to jobs on this page has been completed!")
time_left = minimum_page_time - time.time()
if time_left > 0:
print(f"Sleeping for {time_left} seconds.")
utils.printyellow(f"Sleeping for {time_left} seconds.")
time.sleep(time_left)
minimum_page_time = time.time() + minimum_time
if page_sleep % 5 == 0:
sleep_time = random.randint(5, 34)
print(f"Sleeping for {sleep_time / 60} minutes.")
utils.printyellow(f"Sleeping for {sleep_time / 60} minutes.")
time.sleep(sleep_time)
page_sleep += 1
except Exception:
traceback.print_exc()
traceback.format_exc()
pass
time_left = minimum_page_time - time.time()
if time_left > 0:
print(f"Sleeping for {time_left} seconds.")
utils.printyellow(f"Sleeping for {time_left} seconds.")
time.sleep(time_left)
minimum_page_time = time.time() + minimum_time
if page_sleep % 5 == 0:
sleep_time = random.randint(50, 90)
print(f"Sleeping for {sleep_time / 60} minutes.")
utils.printyellow(f"Sleeping for {sleep_time / 60} minutes.")
time.sleep(sleep_time)
page_sleep += 1
@ -140,20 +140,21 @@ class LinkedInJobManager:
for job in job_list:
if self.is_blacklisted(job.title, job.company, job.link):
print(f"Blacklisted {job.title} at {job.company}, skipping...")
utils.printyellow(f"Blacklisted {job.title} at {job.company}, skipping...")
self.write_to_file(job.company, job.location, job.title, job.link, "skipped")
continue
try:
if job.apply_method not in {"Continue", "Applied", "Apply"}:
self.easy_applier_component.job_apply(job)
except Exception:
except Exception as e:
utils.printred(traceback.format_exc())
self.write_to_file(job.company, job.location, job.title, job.link, "failed")
continue
self.write_to_file(job.company, job.location, job.title, job.link, "success")
except Exception as e:
traceback.print_exc()
traceback.format_exc()
raise e
def write_to_file(self, company, job_title, link, job_location, file_name):
@ -171,8 +172,8 @@ class LinkedInJobManager:
writer = csv.writer(f)
writer.writerow(to_write)
except Exception as e:
print(f"Error writing registered job: {e}")
print(f"Details: Answer type: {answer_type}, Question: {question_text}")
utils.printred(f"Error writing registered job: {e}")
utils.printred(f"Details: Answer type: {answer_type}, Question: {question_text}")
def get_base_search_url(self, parameters):
remote_url = "f_CF=f_WRA" if parameters['remote'] else ""

View File

@ -66,3 +66,17 @@ def chromeBrowserOptions():
else:
options.add_argument("--incognito")
return options
def printred(text):
# Codice colore ANSI per il rosso
RED = "\033[91m"
RESET = "\033[0m"
# Stampa il testo in rosso
print(f"{RED}{text}{RESET}")
def printyellow(text):
# Codice colore ANSI per il giallo
YELLOW = "\033[93m"
RESET = "\033[0m"
# Stampa il testo in giallo
print(f"{YELLOW}{text}{RESET}")