So I want the program to go back to asking for the input once it has completed.
I've asked this in reddit and gone through quite a many similar threads here and so far the answer seems to be loops if true perform x. But what is the command for the program to go back to asking for the input on line 5?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
card = input()
driver = webdriver.Firefox()
driver.get("http://www.mtgprice.com/")
elem = driver.find_element_by_xpath("//form/input")
elem.send_keys(card) # input
driver.implicitly_wait(5) # seconds
driver.find_element_by_class_name('btn-blue').click()
Everyone you asked is pretty much right. Additionally I'd put the chunk of code in a function just because.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
def web_stuff(card):
driver = webdriver.Firefox()
driver.get("http://www.mtgprice.com/")
elem = driver.find_element_by_xpath("//form/input")
elem.send_keys(card) # input
driver.implicitly_wait(5) # seconds
driver.find_element_by_class_name('btn-blue').click()
while loop_condition:
card = input()
web_stuff(card)
Since you don't say what you want to happen over and over again and if you ever want to stop, a starting point is just to put all the driver code into a loop:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
while True:
card = input()
driver = webdriver.Firefox()
driver.get("http://www.mtgprice.com/")
elem = driver.find_element_by_xpath("//form/input")
elem.send_keys(card) # input
driver.implicitly_wait(5) # seconds
driver.find_element_by_class_name('btn-blue').click()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.