滚动iframe中的链接列表

时间:2018-05-09 13:11:53

标签: python selenium

我正在尝试滚动选择过滤器后输出的链接列表。但是当我尝试执行脚本滚动时,它什么也没做。

driver = web.Chrome('/Users/JakesComp/Documents/chromedriver')
driver.get("https://foodmarketmaker.com/main/mmsearch")
iframe = driver.find_element_by_tag_name("iframe")
driver.switch_to.frame(iframe)

wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//section[@id="search-right"]//input[@placeholder="start typing to search"]'))).click()
wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//li[@aria-label="Business Type: Farmer/Rancher"]'))).click()
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
links = wait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, '//section[@id="search-results"]//a[.//*[name()="svg"]]')))

for link in links:
    print(link.get_attribute('href'))

0 个答案:

没有答案