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

TimeoutException #232

Open
jdtibochab opened this issue Nov 29, 2024 · 7 comments
Open

TimeoutException #232

jdtibochab opened this issue Nov 29, 2024 · 7 comments

Comments

@jdtibochab
Copy link

Times out waiting for an element to load (see below). This happens with Person() waiting for "username", and job_search.search() waiting for "jobs-search-results-list". I am not sure why because if I comment on the wait in Person(), everything works fine.

--------------------------------------------------------------------------- TimeoutException Traceback (most recent call last) Cell In[7], line 3 1 from linkedin_scraper import JobSearch 2 job_search = JobSearch(driver=driver, close_on_complete=False, scrape=False) ----> 3 job_listings = job_search.search("Machine Learning Engineer") # returns the list of Job` from the first page

File ~/other/jobs/linkedin_scraper/linkedin_scraper/job_search.py:73, in JobSearch.search(self, search_term)
70 sleep(self.WAIT_FOR_ELEMENT_TIMEOUT)
72 job_listing_class_name = "jobs-search-results-list"
---> 73 job_listing = self.wait_for_element_to_load(name=job_listing_class_name)
74 self.wait(10)
76 self.scroll_class_name_element_to_page_percent(job_listing_class_name, 0.3)

File ~/other/jobs/linkedin_scraper/linkedin_scraper/objects.py:82, in Scraper.wait_for_element_to_load(self, by, name, base)
80 def wait_for_element_to_load(self, by=By.CLASS_NAME, name="pv-top-card", base=None):
81 base = base or self.driver
---> 82 return WebDriverWait(base, self.WAIT_FOR_ELEMENT_TIMEOUT).until(
83 EC.presence_of_element_located(
84 (
85 by,
86 name
87 )
88 )
89 )

File ~/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:105, in WebDriverWait.until(self, method, message)
103 break
104 time.sleep(self._poll)
--> 105 raise TimeoutException(message, screen, stacktrace)

TimeoutException: Message:
Stacktrace:
#0 0x571003f45c5a
#1 0x571003c28e2c
#2 0x571003c75661
#3 0x571003c75751
#4 0x571003cb9f64
#5 0x571003c985ed
#6 0x571003cb7303
#7 0x571003c98363
#8 0x571003c68247
#9 0x571003c68b9e
#10 0x571003f0c22b
#11 0x571003f102d1
#12 0x571003ef7ade
#13 0x571003f10e32
#14 0x571003edc77f
#15 0x571003f35618
#16 0x571003f357f0
#17 0x571003f44d8c
#18 0x7f90bb494ac3
`

@Melchizedek13
Copy link

Melchizedek13 commented Dec 2, 2024

@jdtibochab , thanks for opening this issue!

The same problem.

import os
from pprint import pprint as pp

from linkedin_scraper import actions, Company
from selenium import webdriver

driver = webdriver.Chrome()

def get_linkedin_campaign_info(linkedin_company_url: str):
    linkedin_email = os.environ['LINKEDIN_EMAIL']
    linkedin_password = os.environ['LINKEDIN_PASSWORD']
    actions.login(driver, linkedin_email, linkedin_password)

    return Company(linkedin_company_url, driver=driver)

if __name__ == '__main__':
    pp(
        get_linkedin_campaign_info("https://ca.linkedin.com/company/google")
    )
Traceback (most recent call last):
  File "/Users/nikolaysokolov/git/oxagile/gbs-repo/linkedin_compain_crawler.py", line 22, in <module>
    get_linkedin_campaign_info("https://ca.linkedin.com/company/google")
  File "/Users/nikolaysokolov/git/oxagile/gbs-repo/linkedin_compain_crawler.py", line 18, in get_linkedin_campaign_info
    return Company(linkedin_company_url, driver=driver)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nikolaysokolov/.pyenv/versions/oxa_gbs_3.12/lib/python3.12/site-packages/linkedin_scraper/company.py", line 80, in __init__
    self.scrape(get_employees=get_employees, close_on_complete=close_on_complete)
  File "/Users/nikolaysokolov/.pyenv/versions/oxa_gbs_3.12/lib/python3.12/site-packages/linkedin_scraper/company.py", line 90, in scrape
    self.scrape_logged_in(get_employees = get_employees, close_on_complete = close_on_complete)
  File "/Users/nikolaysokolov/.pyenv/versions/oxa_gbs_3.12/lib/python3.12/site-packages/linkedin_scraper/company.py", line 283, in scrape_logged_in
    self.employees = self.get_employees()
                     ^^^^^^^^^^^^^^^^^^^^
  File "/Users/nikolaysokolov/.pyenv/versions/oxa_gbs_3.12/lib/python3.12/site-packages/linkedin_scraper/company.py", line 131, in get_employees
    _ = WebDriverWait(driver, 3).until(EC.presence_of_all_elements_located((By.XPATH, '//span[@dir="ltr"]')))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nikolaysokolov/.pyenv/versions/oxa_gbs_3.12/lib/python3.12/site-packages/selenium/webdriver/support/wait.py", line 105, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

@kurokirasama
Copy link

i'm getting the same message

@zigpot
Copy link
Contributor

zigpot commented Dec 2, 2024

Hello, I’ve created a pull request (#233) to address this issue. Please take a look and let me know if there’s anything I need to adjust!

@jdtibochab
Copy link
Author

jdtibochab commented Dec 2, 2024

Thanks zigpot, that solves Person(), any insight if this could also be applied to JobSearch? Apologies for the flat text dump, I haven't figured out how to paste code in a pretty way


TimeoutException Traceback (most recent call last)
Cell In[4], line 3
1 from linkedin_scraper import JobSearch
2 job_search = JobSearch(driver=driver, close_on_complete=False, scrape=False)
----> 3 job_listings = job_search.search("Machine Learning Engineer") # returns the list of Job from the first page

File ~/other/jobs/linkedin_scraper/linkedin_scraper/job_search.py:73, in JobSearch.search(self, search_term)
70 sleep(self.WAIT_FOR_ELEMENT_TIMEOUT)
72 job_listing_class_name = "jobs-search-results-list"
---> 73 job_listing = self.wait_for_element_to_load(name=job_listing_class_name)
75 self.scroll_class_name_element_to_page_percent(job_listing_class_name, 0.3)
76 self.focus()

File ~/other/jobs/linkedin_scraper/linkedin_scraper/objects.py:82, in Scraper.wait_for_element_to_load(self, by, name, base)
80 def wait_for_element_to_load(self, by=By.CLASS_NAME, name="pv-top-card", base=None):
81 base = base or self.driver
---> 82 return WebDriverWait(base, self.WAIT_FOR_ELEMENT_TIMEOUT).until(
83 EC.presence_of_element_located(
84 (
85 by,
86 name
87 )
88 )
89 )

File ~/.local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py:105, in WebDriverWait.until(self, method, message)
103 break
104 time.sleep(self._poll)
--> 105 raise TimeoutException(message, screen, stacktrace)

TimeoutException: Message:
Stacktrace:
#0 0x582d76382c5a
#1 0x582d76065e2c
#2 0x582d760b2661
#3 0x582d760b2751
#4 0x582d760f6f64
#5 0x582d760d55ed
#6 0x582d760f4303
#7 0x582d760d5363
#8 0x582d760a5247
#9 0x582d760a5b9e
#10 0x582d7634922b
#11 0x582d7634d2d1
#12 0x582d76334ade
#13 0x582d7634de32
#14 0x582d7631977f
#15 0x582d76372618
#16 0x582d763727f0
#17 0x582d76381d8c
#18 0x7dc2a2494ac3

@zigpot
Copy link
Contributor

zigpot commented Dec 3, 2024

@jdtibochab please check the new PR #234 and let me know.

@jdtibochab
Copy link
Author

jdtibochab commented Dec 3, 2024

Thanks! PR-234 fixes Person, but I am still facing the same error above when calling JobSearch. It waits for "jobs-search-results-list" and times out. It might be a different issue, maybe from my side somehow, will look into it.

@zigpot
Copy link
Contributor

zigpot commented Dec 4, 2024

Thanks! PR-234 fixes Person, but I am still facing the same error above when calling JobSearch. It waits for "jobs-search-results-list" and times out. It might be a different issue, maybe from my side somehow, will look into it.

my bad, it was job, not job search. will look into it in a jiffy!

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

No branches or pull requests

4 participants