Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/v2024.11.23 #960

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ Using this folder as a guide can be particularly helpful for:
python main.py --resume /path/to/your/resume.pdf
```

- **Using the colled mode:**
- **Using the collect mode:**
If you want to collect job data only to perform any type of data analytics you can use the bot with the `--collect` option. This will store in output/data.json file all data found from linkedin jobs offers.

```bash
Expand Down
7 changes: 7 additions & 0 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
DATE_ALL_TIME = "all_time"
DATE_MONTH = "month"
DATE_WEEK = "week"
DATE_24_HOURS = "24_hours"

LINKEDIN = "linkedin"

# constants used in application
SECRETS_YAML = "secrets.yaml"
WORK_PREFERENCES_YAML = "work_preferences.yaml"
Expand Down
270 changes: 193 additions & 77 deletions main.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ webdriver-manager==4.0.2
pytest
pytest-mock
pytest-cov
undetected-chromedriver==3.5.5
42 changes: 2 additions & 40 deletions src/ai_hawk/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

from src.logging import logger

def get_authenticator(driver, platform):
if platform == 'linkedin':
return LinkedInAuthenticator(driver)
else:
raise NotImplementedError(f"Platform {platform} not implemented yet.")

class AIHawkAuthenticator(ABC):

@property
Expand Down Expand Up @@ -56,7 +50,7 @@ def handle_login(self):
def prompt_for_credentials(self):
try:
logger.debug("Enter credentials...")
check_interval = 4 # Interval to log the current URL
check_interval = 45 # Interval to log the current URL
elapsed_time = 0

while True:
Expand All @@ -74,7 +68,7 @@ def prompt_for_credentials(self):
break
else:
# Optionally wait for the password field (or any other element you expect on the login page)
WebDriverWait(self.driver, 10).until(
WebDriverWait(self.driver, 60).until(
EC.presence_of_element_located((By.ID, "password"))
)
logger.debug("Password field detected, waiting for login completion.")
Expand All @@ -88,35 +82,3 @@ def prompt_for_credentials(self):
@abstractmethod
def handle_security_checks(self):
pass

class LinkedInAuthenticator(AIHawkAuthenticator):

@property
def home_url(self):
return "https://www.linkedin.com"

def navigate_to_login(self):
return self.driver.get("https://www.linkedin.com/login")

def handle_security_checks(self):
try:
logger.debug("Handling security check...")
WebDriverWait(self.driver, 10).until(
EC.url_contains('https://www.linkedin.com/checkpoint/challengesV2/')
)
logger.warning("Security checkpoint detected. Please complete the challenge.")
WebDriverWait(self.driver, 300).until(
EC.url_contains('https://www.linkedin.com/feed/')
)
logger.info("Security check completed")
except TimeoutException:
logger.error("Security check not completed. Please try again later.")

@property
def is_logged_in(self):
keywords = ['feed', 'mynetwork','jobs','messaging','notifications']
return any(item in self.driver.current_url for item in keywords) and 'linkedin.com' in self.driver.current_url

def __init__(self, driver):
super().__init__(driver)
pass
3 changes: 2 additions & 1 deletion src/ai_hawk/bot_facade.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from ai_hawk.job_manager import AIHawkJobManager
from src.logging import logger


Expand Down Expand Up @@ -28,7 +29,7 @@ class AIHawkBotFacade:
def __init__(self, login_component, apply_component):
logger.debug("Initializing AIHawkBotFacade")
self.login_component = login_component
self.apply_component = apply_component
self.apply_component : AIHawkJobManager = apply_component
self.state = AIHawkBotState()
self.job_application_profile = None
self.resume = None
Expand Down
Loading
Loading