当我使用 Selenium 运行 googletag 参数时,我尝试从浏览器的控制台中获取一些响应,但不幸的是我没有。
我已经尝试过 .execute_async_script('googletag.pubads()')
也可以将所有内容放入尝试/执行中,但即使我没有得到任何答复,也永远不会调用执行。
这是我的代码:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
url = 'https://joursferies.fr'
d = DesiredCapabilities.CHROME
d['loggingPrefs'] = { 'browser':'ALL' }
browser = webdriver.Chrome(desired_capabilities=d)
browser.get(url)
browser.execute_script('googletag.openConsole()')
# Until here everything is perfect but with the following line is when I never get any answer:
browser.execute_script('googletag.pubads()')
我期望浏览器检查中的控制台会向我显示信息,但它没有显示任何内容。
最佳答案
尝试添加 return,browser.execute_script('return googletag.openConsole()')
关于javascript - 尝试执行 driver.execute_script(gooogletag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58523897/