NathanDuma / LinkedIn-Easy-Apply-Bot

Automate LinkedIn Easy Apply job applications and answer application-specific questions.
223 stars 84 forks source link

Failure to apply to jobs, seeminly caused by inability to find the correct elements #42

Open theusernamewhichismine opened 2 years ago

theusernamewhichismine commented 2 years ago

Line 123 in linkedineasyapply.py try: job_results = self.browser.find_element_by_class_name("jobs-search-results") self.scroll_slow(job_results) self.scroll_slow(job_results, step=300, reverse=True)

This bit was what made it scroll through the jobs list up and down. the find_element_by_class_name appears to be the problem as that element is now called "jobs-search-results-list". If I change the line to read

        job_results = self.browser.find_element_by_class_name("jobs-search-results-list")

Then it will successfully scroll through the list up and down.

After that however I'm stuck and can't fix it. At line 128

        job_list = self.browser.find_elements_by_class_name('jobs-search-results__list')[0].find_elements_by_class_name('jobs-search-results__list-item')

This bit was what made it actually find the jobs themselves. Again the elements seem to be misnamed now, possibly due to a LinkedIn update, but I can't seem to make it find the jobs. It instead goes straight to raising the exception "No more jobs on this page".

I'm just not that good at inspecting elements so I don't know how to fix it. There is a div class "job-search-results-list" within which is a ul class "scaffold-layout__list-container" within which are the "li id" items for each job, with the following

class="ember-view jobs-search-resultslist-item occludable-update p0 relative scaffold-layoutlist-item

        "

So I'm not sure how to update that line to make it find each of these proper elements. But I know exactly where it is failing.

theusernamewhichismine commented 2 years ago

Actually I seem to have fixed it with the following edit. Lines 123 through 128 currently read

    try:
        job_results = self.browser.find_element_by_class_name("jobs-search-results")
        self.scroll_slow(job_results)
        self.scroll_slow(job_results, step=300, reverse=True)

        job_list = self.browser.find_elements_by_class_name('jobs-search-results__list')[0].find_elements_by_class_name('jobs-search-results__list-item')

I changed them to read

    try:
        job_results = self.browser.find_element_by_class_name("jobs-search-results-list")
        self.scroll_slow(job_results)
        self.scroll_slow(job_results, step=300, reverse=True)

        job_list = self.browser.find_elements_by_class_name('scaffold-layout__list-container')[0].find_elements_by_class_name('jobs-search-results__list-item')

And it started working. Now I don't really know how github version controlling works, I do version control by naming things finalFINAL2 etc, but editing linkedineasyapply.py in this way fixes the issue

logix727 commented 2 years ago

This worked for you? it is not for me what else did u change?

theusernamewhichismine commented 2 years ago

That change on lines 123 through 128 was the only change I made, sorry it isn't working for you. Did you replace the lines completely?

osama3101995 commented 1 year ago

Can confirm this is the fix. However, it seems to be causing issues on last 1-2 jobs and throws error log, and continue onwards

Can you please tell us how we can contribute to this project? as I also tried to update the code and couldn't do it.

theusernamewhichismine commented 1 year ago

Update update, although that fix worked previously, the LinkedIn UI seems to have reverted to what it used to be. My fix no longer works and the original easyapply.py code is now working. I don't know if LinkedIn is deliberately switching up the UI to shake out botting like this, or if it's just normal UI updates and tests. Regardless, I wanted to write down for posterity how you, the read can try to fix this in the future if the UI changes again, since it seems this repo isn't being actively updated.

If the bot manages to open Chrome and sign in to LinkedIn, but then fails to scroll through the job list or make any application, then it's probably not finding the correct UI elements (this can be confirmed by looking at the error messages in the command line log). If you log in to LinkedIn on Chrome, you can go to the jobs page and hit F12 to open up the element inspector. On the top right of your screen you will now have a pane that says "elements" at the top and will let you see what every element of the webpage is called. Hovering over any line in that elements pane will highlight what element it is referencing. For instance, hovering over.

Each element that begins with "<div class =" is where you want to start looking. So currently the results list is

And hover over that will give you a list of all the jobs. Now you can use those UI elements to change what element names easyapply.py is looking for, in case LinkedIn ever updates their site UI again.
osama3101995 commented 1 year ago

Can we create a new repository of this and push our updates there? Since I am also sometimes updating this project with new features (I am not a python dev btw)? Can we somehow get approval of the main dev??

zszszz commented 1 year ago

Curious as to any more fixes for this. Experiencing same issue and tried both versions of code (modified and original) mentioned in this issue

logix727 commented 1 year ago

post your code u need 2 fixes

On Tue, Sep 13, 2022 at 5:34 PM ss @.***> wrote:

Curious as to any more fixes for this. Experiencing same issue and tried both versions of code (modified and original) mentioned in this issue

— Reply to this email directly, view it on GitHub https://github.com/NathanDuma/LinkedIn-Easy-Apply-Bot/issues/42#issuecomment-1245976637, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEPXCRW3KP4BFJT5XYNYD2DV6DXPHANCNFSM54X5ZXDQ . You are receiving this because you commented.Message ID: @.***>

zszszz commented 1 year ago

Code below currently

        try:
            job_results = self.browser.find_element(By.CLASS_NAME, "jobs-search-results-list")
            self.scroll_slow(job_results)
            self.scroll_slow(job_results, step=300, reverse=True)

            job_list = job_results.find_elements(By.CLASS_NAME, 'scaffold-layout__list-container')[0].find_elements_by_class_name('jobs-search-results__list-item')
        except:
            raise Exception("No more jobs on this page")

        if len(job_list) == 0:
            raise Exception("No more jobs on this page")

        for job_tile in job_list:
            job_title, company, job_location, apply_method, link = "", "", "", "", ""

            try:

                job_list = job_results.find_elements_by_class_name('scaffold-layout__list-container')[0].find_elements_by_class_name('scaffold-layout__list-item')
                job_title = job_tile.find_element_by_class_name('job-card-list__title').text
                link = job_tile.find_element_by_class_name('job-card-list__title').get_attribute('href').split('?')[0]
zszszz commented 1 year ago

The above code is working now suddenly

xMacJ commented 1 year ago

Hmm the above code change seems to scroll to the job list and do nothing image

xMacJ commented 1 year ago

image