Python Chrome驱动程序,单击Safari Web浏览器上的阅读器视图

问题描述 投票:0回答:1

[抓取网站时如何在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. 

enter image description here

python selenium selenium-chromedriver screen-scraping
1个回答
0
投票

您能否将快捷方式发送到启用了阅读器视图的页面?我还没有尝试下面的代码,但希望它能对您有所帮助。

reader_view = Keys.chord(Keys.SHIFT, Keys.COMMAND, "r");
driver.findElement(By.Xpath("//something")).sendKeys(selectAll);
© www.soinside.com 2019 - 2024. All rights reserved.