如何在Python的selenium中控制标签页?

2024-04-25 00:52:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个阻止在chrome上玩游戏的代码。 问题是当我打开一个新标签时,我可以做任何我想做的事情

from selenium import webdriver
import selenium
import chromedriver_binary
from selenium.webdriver.common.keys import Keys
blocker = webdriver.Chrome()
blocker.get("https://www.google.co.il/?hl=iw")
while True:
    if 'game' in blocker.page_source:
        blocker.back()

Tags: 代码fromimportselenium标签commonkeyschrome