I have been struggling on this for a while.
I want it to always be searching for this class name and trigger the code below it when the class is found. I dont want the script below it to be active until the class name is present. Until a pop up box is present for example.
I am using selenium and webdriver.
I am trying to make this work:
while not driver.find_element_by_class_name("rc-anchor-pt"):
sleep(10)
#driver.refresh()
#time.sleep(random.randint(2,3))
#code below it I want to run whenever the class name is found and present
driver.find_element_by_xpath("/html/body/div/div/div[3]/div/button").click()
#get the mp3 audio file
src = driver.find_element_by_id("audio-source").get_attribute("src")
print("[INFO] Audio src: %s"%src)
#download the mp3 audio file from the source
urllib.request.urlretrieve(src, os.getcwd()+"\\sample.mp3")
sound = pydub.AudioSegment.from_mp3(os.getcwd()+"\\sample.mp3")
sound.export(os.getcwd()+"\\sample.wav", format="wav")
sample_audio = sr.AudioFile(os.getcwd()+"\\sample.wav")
r= sr.Recognizer()
Aucun commentaire:
Enregistrer un commentaire