【问题标题】:How to get user agent information in Selenium WebDriver with Python如何使用 Python 在 Selenium WebDriver 中获取用户代理信息
【发布时间】:2018-12-31 03:16:03
【问题描述】:

我正在尝试获取我在 Selenium 中使用的实际用户代理,目前使用 chromedriver

我发现了这个问题的 Java 版本: How to get userAgent information in Selenium Web driver.

有人知道如何在 Python 中做到这一点吗?

【问题讨论】:

标签: python selenium selenium-webdriver web-scraping selenium-chromedriver


【解决方案1】:

与链接中的方式相同:

user_agent = driver.execute_script("return navigator.userAgent;")

PS: 使用execute_script 方法你可以在你的驱动中运行JS。

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 2014-01-26
    • 2018-03-03
    • 1970-01-01
    • 1970-01-01
    • 2011-11-07
    • 2014-12-06
    相关资源
    最近更新 更多