from selenium import webdriver as web
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait as wait
driver = web.Chrome()
driver.get('http://www.soccerpro.com/Clearance-Soccer-Shoes-c168/')
wait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//table[@class='getproductdisplay-innertable']")))
links = [link.get_attribute('href') for link in driver.find_elements_by_xpath('//a[@class="newnav itemnamelink"]')]
所需的链接是动态生成的,因此您无法从
HTML
源中获取它们,就像requests.get("http://www.soccerpro.com/Clearance-Soccer-Shoes-c168/")
您可以使用
selenium
通过浏览器会话获取所需的值:相关问题 更多 >
编程相关推荐