Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help writing code for a bot i have made in PYTHON. The problem is right n

ID: 3708875 • Letter: I

Question

I need help writing code for a bot i have made in PYTHON. The problem is right now that I am trying to search for item on webpage and if not found refresh that web page until when the web page loads the item is there. I have an if statement right now that when not found it refreshes but it only refreshes one time. I need it to continue refreshing until that item is found.

items = driver.find_elements_by_xpath("//article[.//a[contains(.,'MLK')]][.//a[.='Rainbow']]//a")

if items:

items[0].click()

else:

driver.get("http://www.supremenewyork.com/shop/all/sweatshirts")

That is the code I have now for refreshing if not found. Only refreshes once if someone could help me and let me know the correct code i need to have it refresh until item is found that would be great.
Thank You

Explanation / Answer

To continue refreshing until the item is found, you will need to use the loop.

You can use the selenium web driver with python to resolve this: