import time from selenium import webdriver import win32com.client speaker = win32com.client.Dispatch("SAPI.SpVoice")
时间: 2023-11-27 11:02:42 浏览: 159
# Create a new instance of the Firefox driver
driver = webdriver.Firefox()
# Open the website you want to scrape
driver.get("https://www.example.com")
# Wait for 5 seconds to allow the page to fully load
time.sleep(5)
# Use the find_element_by_xpath method to locate the element you want to scrape
element = driver.find_element_by_xpath("//h1[@class='title']")
# Use the text attribute to extract the text content of the element
text_content = element.text
# Print the scraped content to the console
print(text_content)
# Use the Speak method of the speaker object to speak the scraped content
speaker.Speak(text_content)
# Close the browser window
driver.quit()
阅读全文