I am trying to make the code find a certain text on a website. This is probably very very basic, but I am very very new to this... So, I am wanting my code to read the website, and if it finds a certain text, which in my case is, "Currently unavailable.", it will continue the code and keep refreshing the page. Here is what my code is right now:
import time from selenium import webdriver # browser = webdriver.Chrome('D:\ChromeDriver\chromedriver.exe') # browser.get("https://www.amazon.com/TEAMGROUP-T-Force-Vulcan-3000MHz-Desktop/dp/B07QRSPFG7/") # import time time.sleep(10) # buyButton = False # while not buyButton: # try: addToCartBtn = addButton = (this is where I need to put the code to find the text, but I don't know how to) # print("Not in Stock") # time.sleep browser.refresh() Sorry, mind the #, that is just a space in lines in my code.
So, if I put a href or a find element in there, it works fine, but since I am looking for a text, it is not an element or a href. I do not know if I need to change the whole entire line of addToCartBtn = addButton = (blah blah blah)
If I need to change it, I am more than happy to do so.
Here is the text that I am wanting to put in for the addButton = (this is where I am putting in the text) https://i.sstatic.net/TYstF.png
(Sorry, I don't know how to add it as the whole code HTML, and I would rather not type out the whole thing, and I could not add a photo because I do not have 15 reputation, lol. Sorry!)
The "Currently unavailable." is what I am wanting the code to check. I want it to see if that text is on the page, and if so, continue the code, which I have tested and is working.
If anyone could help, that would be great!
Thank you in advance!
<div id="availability_feature_div" ...>, choose Edit as HTML, select all, and copy. Then put it through a beautfier and do some manual cleanup. Then you can come back and add it to your question as properly formatted code.