我对python/selenium相当陌生,我对如何缩进这段特定的代码有个问题。代码:
articles = driver.find_elements_by_tag_name('article')
for article in articles:
ActionChains(driver).move_to_element(article).perform()
if article.find_element_by_tag_name('a').text == "sold out":
print("sold out")
else:
print("available")
shirts = driver.find_elements_by_xpath("""//*[@id='container']/article/div/h1/a""")
colors = driver.find_elements_by_xpath("""//*[@id='container']/article/div/p/a""")
for shirt, color in zip(shirts, colors):
shirt_text = shirt.text
color_text = color.text
print shirt_text, color_text
link = article.find_element_by_xpath('div/a').get_attribute('href')
print(link)发布于 2018-05-21 00:13:40
articles = driver.find_elements_by_tag_name('article')
for article in articles:
ActionChains(driver).move_to_element(article).perform()
if article.find_element_by_tag_name('a').text == "sold out":
print("sold out")
else:
print("available")
shirts = driver.find_elements_by_xpath("""//*[@id='container']/article/div/h1/a""")
colors = driver.find_elements_by_xpath("""//*[@id='container']/article/div/p/a""")
for shirt, color in zip(shirts, colors):
shirt_text = shirt.text
color_text = color.text
print shirt_text, color_text
link = article.find_element_by_xpath('div/a').get_attribute('href')
print(link)https://stackoverflow.com/questions/50440426
复制相似问题