3
我使用Clojure的有CLJ-webdriver的,像這樣:如何爲clj-webdriver中的phantomjs驅動程序設置useragent?
(set-driver! {:browser :phantomjs} "url")
如何設置用戶代理?
我使用Clojure的有CLJ-webdriver的,像這樣:如何爲clj-webdriver中的phantomjs驅動程序設置useragent?
(set-driver! {:browser :phantomjs} "url")
如何設置用戶代理?
對於CLJ-0.6.1的webdriver與PhantomJS支持您可以通過設置能力做到這一點
(ns site-test
(:require [clj-webdriver.taxi :refer :all]
[clj-webdriver.driver :refer [init-driver]])
(:import (org.openqa.selenium.phantomjs PhantomJSDriver)
(org.openqa.selenium.remote DesiredCapabilities)))
(System/setProperty "phantomjs.binary.path" "D:/Drivers/phantomjs-1.9.7-windows/phantomjs.exe")
(set-driver!
(init-driver
{:webdriver
(PhantomJSDriver. (doto (DesiredCapabilities.)
(.setCapability "phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
(.setCapability "phantomjs.page.customHeaders.Accept-Language" "en-US")
(.setCapability "phantomjs.page.customHeaders.Connection" "keep-alive")
(.setCapability "phantomjs.cli.args" (into-array String ["--ignore-ssl-errors=true"
"--webdriver-loglevel=WARN"]))))}))