如何通过延迟加载硒网络抓取

时间:2021-04-30 18:31:22

标签: python-3.x selenium

我想从以下站点中获取超过前 10 个条目,但它似乎只有在您向下滚动网页时才会加载。关于如何获取超过前 10 个条目的任何想法?< /p>

站点 here

示例代码:

driver.get(g)
price = [i.text for i in WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, "//div[@data-test='event-listing']//a/span")))]
price = [x.replace('\n', '') for x in price] #added to get rid of newline character in each list element
price = [x.replace('/ea', '') for x in price] #added to get rid of newline character in each list element
loc = [i.text for i in WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, "//div[@data-test='event-listing']//div[@data-test='section']")))]
detail = [i.text for i in WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, "//div[@data-test='event-listing']//span[@data-test='quantity']")))]

0 个答案:

没有答案