from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver
path='/home/d../phantomjs/bin/phantomjs'
dcap = DesiredCapabilities.PHANTOMJS
dcap['platform']=('Windows')
dcap['browserName'] = ('chrome')
dcap['version'] = ('15.0.87')
driver = webdriver.PhantomJS(executable_path=path,
desired_capabilities=dcap,
service_args=['--ignore-ssl-errors=true', '--ssl-protocol=TLSv1'])
url = "https://www.whatismybrowser.com/"
driver.get(url)
# The code below returns what the site sees as my browser
a = driver.find_element_by_class_name('string-major')
print("Browser type is : {}".format(a.text) )
https://gist.github.com/dgsbicak/4e4e450a9d78a16272563fe33d6dc5da
这是我看到代码的地方: http://selenium-python.readthedocs.io/api.html#desired-capabilities
代码返回:
浏览器类型是:Linux上基于Webkit的浏览器
如何使用PhantomJS更改标题?
您是否更了解使用无头驱动程序更好的废弃方法? (我想完全匿名。)
请分享您关于此主题的文档或来源。
注意:我不懂JS或Java。只有python。
最诚挚的问候,