[抓取网站时如何在Safari浏览器中单击“阅读器视图”?
URL:https://www.w3resource.com/java-exercises/collection/index.php
我需要一个Python脚本来单击阅读器视图,然后将所有内容复制到文本文件。
请查看我当前代码的摘录:
options = webdriver.ChromeOptions()
driver = webdriver.Chrome('/usr/local/bin/chromedriver', options=options)
url = "https://www.w3resource.com/java-exercises/collection/index.php"
# TODO: Click Reader View.
# Copy all text on Reader View to a string variable.
# Paste string to a text file.
您能否将快捷方式发送到启用了阅读器视图的页面?我还没有尝试下面的代码,但希望它能对您有所帮助。
reader_view = Keys.chord(Keys.SHIFT, Keys.COMMAND, "r");
driver.findElement(By.Xpath("//something")).sendKeys(selectAll);