我做了一个python程序,我想设置产品的大小,点击addtocart按钮。所以要启用,我应该设置大小。如何使用selenium键设置大小?另外,我希望这个程序适用于不需要设置大小的产品,这个程序适用于这种产品(例如this product)
所以我想设置大小以启用添加到购物车。代码应该在(driver.get(url))
之后。我附上了程序。我会很感激你的帮助。在
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.keys import Keys
proxies = {
'http': 'http://217.119.82.14:8080',
'https': 'http://196.27.107.30:8080',
}
url = "https://www.amazon.com/Disney-Stitch-Surfer-Adult-T-shrt/dp/B072VPQ1BG/ref=sr_1_4?ie=UTF8&qid=1517916607&sr=8-4&keywords=t+shrt"
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % proxies)
driver = webdriver.Chrome(executable_path="C:\\Users\Andrei\Downloads\chromedriver_win32\chromedriver.exe",
chrome_options=chrome_options)
driver.get(url)
driver.find_element_by_xpath('//*[@id="submit.add-to-cart"]/span/input').click()
要设置所需大小,可以使用Select类:
您可以通过id直接获得项目的大小,但是首先,您需要单击size菜单
检查页面上是否有可以添加的菜单
^{pr2}$相关问题 更多 >
编程相关推荐