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

fix: 🐛 Hotfix. Change selectors due to new html structure #905

Conversation

chakaponi
Copy link
Contributor

LinkedIn has changed their HTML structure therefore app stopped to apply to jobs

waterstark and others added 21 commits November 5, 2024 16:03
repalced union with base class.
Some providers (as OpenAI) support reducing cost of calls by caching repetitive content, but the feature works only with the initial portion (prefix) of prompts
included links to AI/ML API docs and the endpoint to be used in the code.
…-caching

perf: ⚡ Optimize prompt for better caching
(cherry picked from commit 6b23715)
(cherry picked from commit c75f78f)
@chakaponi chakaponi force-pushed the bug/incorrect-element-selectors branch from bc83944 to a603455 Compare November 21, 2024 18:56
@chakaponi
Copy link
Contributor Author

Sorry, I supposed to begin branch name with "hotfix" instead of "bug"

@chakaponi
Copy link
Contributor Author

Currently, only the selectors that I have changed have been tested for changes on LinkedIn side. There might be more

@chakaponi chakaponi changed the title fix: 🐛 Change selectors due to new html structure fix: 🐛 Hotfix. Change selectors due to new html structure Nov 21, 2024
@surapuramakhil
Copy link
Contributor

surapuramakhil commented Nov 21, 2024

@chakaponi released hotfix, I just applied - automation didn't break. can you explain on impact on description

@surapuramakhil surapuramakhil changed the base branch from main to release/v4.1.0 November 21, 2024 19:47
@chakaponi
Copy link
Contributor Author

@surapuramakhil Discord's having auth problems so I can't use it. Only telegram

@surapuramakhil
Copy link
Contributor

@chakaponi not able to find you. can you ping me on telegram

@surapuramakhil
Copy link
Contributor

thread link for sharing your jobs view structure, for having a fix which works for all.

https://discord.com/channels/1300208460788400159/1310293395226230896

run this command on dev tools console

copy($('#main'))

you can run copy($('#main')) in your chrome dev tools on, for example, this page: https://www.linkedin.com/jobs/search/?currentJobId=4042558197&distance=10&f_E=4&f_LF=f_AL&f_WT=2&keywords=JavaScript%20Developer&location=Mexico It will copy element which contain currently open job and block with list of jobs (left sidebar)

Current solution is fine for hotfix, but not as constant
@surapuramakhil
Copy link
Contributor

@chakaponi can you test hotfix branch? and see if this required

@feder-cr
Copy link
Collaborator

@chakaponi hello, if it is no longer useful remove it with no problem!

@chakaponi
Copy link
Contributor Author

@surapuramakhil Hotfix branch has been merged into mine with some changes and rewritten tests. All tests pass. Works in normal environment for me.

src/ai_hawk/job_manager.py Outdated Show resolved Hide resolved
src/ai_hawk/job_manager.py Outdated Show resolved Hide resolved
src/ai_hawk/job_manager.py Show resolved Hide resolved
src/ai_hawk/job_manager.py Outdated Show resolved Hide resolved
src/ai_hawk/job_manager.py Outdated Show resolved Hide resolved
src/ai_hawk/job_manager.py Outdated Show resolved Hide resolved
src/ai_hawk/job_manager.py Outdated Show resolved Hide resolved
tests/test_aihawk_job_manager.py Outdated Show resolved Hide resolved
@surapuramakhil
Copy link
Contributor

@chakaponi can you comment on #927 #926 so that I can assign those to you.

@Shuo-Wang-UCBerkeley
Copy link

Hi guys, I git clone the hotfix/v2024.11.23, but still does not work.

image

@surapuramakhil surapuramakhil merged commit 65f8ac9 into AIHawk-FOSS:hotfix/v2024.11.23 Nov 25, 2024
1 check passed
@surapuramakhil
Copy link
Contributor

@chakaponi Next time don't force push. It corrupts subsequent processes.

@Shuo-Wang-UCBerkeley
Copy link

Thank you for your effort @surapuramakhil , may I ask if the issue has fixed?
Do I need to get clone again for the AIHawk-FOSS:hotfix/v2024.11.23?

@chakaponi Next time don't force push. It corrupts subsequent processes.

@surapuramakhil
Copy link
Contributor

surapuramakhil commented Nov 25, 2024

Thank you for your effort @surapuramakhil , may I ask if the issue has fixed?
Do I need to get clone again for the AIHawk-FOSS:hotfix/v2024.11.23?

just update your main.

git fetch 
git pull

if you face errors then clone again.

jobs_container = self.driver.find_element(By.CLASS_NAME, 'scaffold-layout__list-container')
# XPath query to find the ul tag with class scaffold-layout__list-container
jobs_xpath_query = "//ul[contains(@class, 'scaffold-layout__list-container')]"
jobs_container = self.driver.find_element(By.XPATH, jobs_xpath_query)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They unlikely will keep this class with not ul tag so both approaches are equal

Copy link
Contributor Author

@chakaponi chakaponi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some bad approaches is choosen. Needs partial revert

Please notice me after revert so I will be able to be sure that we are getting working approach

@@ -262,7 +264,7 @@ def get_jobs_from_page(self, scroll=False):
browser_utils.scroll_slow(self.driver, jobs_container_scrolableElement)
browser_utils.scroll_slow(self.driver, jobs_container_scrolableElement, step=300, reverse=True)

job_element_list = jobs_container.find_elements(By.CSS_SELECTOR, 'div[data-job-id]')
job_element_list = jobs_container.find_elements(By.XPATH, ".//li[contains(@class, 'jobs-search-results__list-item') and contains(@class, 'ember-view')]")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that rely on "ember-view" instead of "data-job-id" more likely to cause problems again so I would revert this change

@@ -483,7 +473,7 @@ def job_tile_to_job(self, job_tile) -> Job:
logger.warning("Job link is missing.")

try:
job.company = job_tile.find_element(By.XPATH, './/span[contains(normalize-space(), " · ")]').text.split(' · ')[0].strip()
job.company = job_tile.find_element(By.XPATH, ".//div[contains(@class, 'artdeco-entity-lockup__subtitle')]//span").text
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not robust. Also advise to revert

@@ -500,15 +490,21 @@ def job_tile_to_job(self, job_tile) -> Job:
logger.warning(f"Failed to extract job ID: {e}", exc_info=True)

try:
job.location = job_tile.find_element(By.XPATH, './/span[contains(normalize-space(), " · ")]').text.split(' · ')[-1].strip()
job.location = job_tile.find_element(By.CLASS_NAME, 'job-card-container__metadata-item').text
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply doesn't work. If we check, 'job-card-container__metadata-item' never follow as to location, but to salary fork. Has to be reverted with no doubt

try:
job.apply_method = job_tile.find_element(By.XPATH, ".//div[contains(@class, 'job-card-container__job-insight-text') and normalize-space() = 'Easy Apply']").text
job_state = job_tile.find_element(By.XPATH, ".//ul[contains(@class, 'job-card-list__footer-wrapper')]//li[contains(@class, 'job-card-container__apply-method')]").text
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't work. Return empty array all of the time. Revert

@chakaponi
Copy link
Contributor Author

@surapuramakhil If you want to keep your approach, you can rewrite code a little and keep both so if one class returns an empty array we could try other one right after

@surapuramakhil
Copy link
Contributor

My Apologies @chakaponi as this was breaking change, I took decision for "quicker release, for pushing fix which at least work, than no fix at all".

  1. we can update this in release branch (more robust)
  2. only if main breaks - we can push this two second hotfix

@Shuo-Wang-UCBerkeley
Copy link

Thank you for your great work on this. @surapuramakhil and @chakaponi
May I ask which branch works now?
so I can git clone and start the job application.

@chakaponi
Copy link
Contributor Author

My Apologies @chakaponi as this was breaking change, I took decision for "quicker release, for pushing fix which at least work, than no fix at all".

  1. we can update this in release branch (more robust)
  2. only if main breaks - we can push this two second hotfix

Don't get it. My fix was ready and tested so why wouldn't have used it
Anyways, we need second hotfix as long as current fix doesn't work

@chakaponi
Copy link
Contributor Author

chakaponi commented Nov 25, 2024

Thank you for your great work on this. @surapuramakhil and @chakaponi May I ask which branch works now? so I can git clone and start the job application.

Main branch may work if you are lucky enough. If not, try this branch, but with reverted commit with hash 22f2c3b
We really would appreciate if you try both and tell us which ones works for you. Thank you

@surapuramakhil
Copy link
Contributor

Anyways, we need second hotfix as long as current fix doesn't work

created a poll to see if the main branch works or not. #919 (comment)

@surapuramakhil
Copy link
Contributor

surapuramakhil commented Nov 26, 2024

@chakaponi I have created the hotfix branch. Please raise a PR to the hotfix branch.

DanielT504 pushed a commit to DanielT504/Auto_Jobs_Applier_AI_Agent that referenced this pull request Dec 21, 2024
…nt-selectors

fix: 🐛 Hotfix. Change selectors due to new html structure

Co-authored-by: chakaponi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]: Not applying to jobs
10 participants