1

i want to get source from a job listing site but when i click on a job link and get description than come back get_attribute() method gets broken.i am new to this stuff so i need some help on this.

my code:

all_jobs = driver.find_elements_by_class_name("index-middle")

for job in all_jobs:

 result_html = job.get_attribute("innerHTML")
 soup = BeautifulSoup(result_html, "html.parser")

  showmore=WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.CLASS_NAME,'job')))
            
  showmore.click()
 
 
 try:
     description = soup.find("a",class_="desc").text
 except:
     description = "None"

 driver.execute_script("window.history.go(-1)")


i want to repeat this action in for loop but when it gets a one job description it gives error.

error:

  Traceback (most recent call last):
    File "joblist.py", line 46, in <module>
    result_html = job.get_attribute("innerHTML")
selenium.common.exceptions.StaleElementReferenceException: Message: stale element
reference: element is not attached to the page document

what should i do ?

eminvergil
  • 45
  • 1
  • 6

0 Answers0