0
from selenium import webdriver
import time
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
import pandas as pd
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait


options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1920x1080")
options.add_argument("--disable-extensions")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
                    
URL = 'https://gemelnet.cma.gov.il/views/dafmakdim.aspx'
driver.get(URL)
time.sleep(2)


review=WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//input[@id='knisa']")))
review.click()

table=WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='Aaaa89455bbfe4387b92529246ea52dc6114']//font"))).text()
print(table)

I am trying to extract the table but they give me raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: how I solve these error any recommendation.
Kindly tell me what mistake I will be doing this is page link https://gemelnet.cma.gov.il/views/dafmakdim.aspx

enter image description here

   table 

enter image description here

1
  • //div[@class='Aaaa89455bbfe4387b92529246ea52dc6114']//font selector doesn't exist. Because you use webdriver wait instead of implicit wait, you didin't get element not found exception. Commented Nov 30, 2022 at 9:47

1 Answer 1

0

There are several issues you need to improve here:

  1. The Aaaa89455bbfe4387b92529246ea52dc6114 class you trying to use is a dynamic value. This can't be used as a locator.
  2. The first element you clicking to enter the system - you should wait for element clickability, not only visibility. These conditions are almost similar, but since you are going to click the element clickability should be checked. Visibility is normally used when we are going to extract the text form that element.
  3. No need to add time.sleep(2) before review=WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//input[@id='knisa']")))
  4. You can apply click directly on the web element object returned by WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//input[@id='knisa']"))), no need to store it into review temporary variable.
  5. The table you trying to print initially presents "Loading" content. So, to overcome this problem I'm waiting for one of it columns to appear , add some more delay and then get the entire table text.

Not ideally, but the following is worked:

import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument("start-maximized")

webdriver_service = Service('C:\webdrivers\chromedriver.exe')
driver = webdriver.Chrome(options=options, service=webdriver_service)
wait = WebDriverWait(driver, 10)

url = "https://gemelnet.cma.gov.il/views/dafmakdim.aspx"
driver.get(url)

wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='knisa']"))).click()
wait.until(EC.visibility_of_element_located((By.XPATH, "//td[contains(.,'קרנות השתלמות')]")))
time.sleep(2)
table = wait.until(EC.visibility_of_element_located((By.XPATH, "//table[@id='ReportViewer1_fixedTable']"))).text
print(table)

The output is:

30/11/2022
(30/11/2022)
סה"כ נכסי הקופות - לפי סוג קופה
(במיליוני ש"ח)
נכון לסוף אוקטובר 2022
תשואה שנתית
סה"כ נכסים
קופ"ג להשקעה- חסכון לילד
קופ"ג להשקעה
מטרה אחרת
מרכזית לפיצויים
קרנות השתלמות
תגמולים ואישית לפיצויים
שנת דיווח
   ---   
648,227
14,480
34,775
946
10,806
303,352
283,869
2022
12.33%
688,304
14,441
34,409
1,043
12,370
321,477
304,565
2021
4.58%
579,438
10,997
20,172
950
12,022
272,631
262,666
2020
11.77%
511,987
---
---
933
13,463
250,174
247,416
2019
התשואה הממוצעת בענף קופות גמל
-6.66%
ב- 12 חודשים האחרונים עמדה על
 

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.