擅长:python、mysql、java
<p>网站正在花时间加载<code>table</code>中的数据</p>
<p>要么应用<code>time.sleep</code></p>
<pre><code>import time
driver.get('https://www.erstebank.hr/hr/tecajna-lista')
time.sleep(10)...
</code></pre>
<p>或者应用<code>Explicit wait</code>,以便将<code>rows</code>加载到<code>tabel</code>中</p>
<pre><code>import requests
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Chrome(executable_path="path to chromedriver.exe")
driver.maximize_window()
driver.get('https://www.erstebank.hr/hr/tecajna-lista')
wait = WebDriverWait(driver,30)
wait.until(EC.presence_of_all_elements_located((By.XPATH,"//table/tbody/tr[@class='ng-scope']")))
# driver.find_element_by_id("popin_tc_privacy_button_2").click() # Cookie setting pop-up. Works fine even without dealing with this pop-up.
soup = BeautifulSoup(driver.page_source, 'html5lib')
table = soup.find_all('table')
print(table)
</code></pre>