2
我想在Python上使用BrowserMob Proxy和browsermob-proxy-py。我需要捕獲來自頁面的所有請求的URL。但我無法在HAR文件中找到https請求。 Selenium和BrowserMob Proxy正在遠程機器上運行。BrowserMob Proxy +硒捕獲https請求
示例代碼:
from selenium import webdriver
import browsermobproxy
SELENIUM_EXECUTOR = 'http://<remote_ip>:4444/wd/hub'
SELENIUM_DESIRED_CAPABILITIES = {
'browserName': 'firefox',
'version': '20.0.0',
'javascriptEnabled': True,
}
prox = browsermobproxy.Client('<remote_ip>:8080')
driver = webdriver.Remote(
command_executor=SELENIUM_EXECUTOR,
desired_capabilities=SELENIUM_DESIRED_CAPABILITIES,
proxy=prox)
url_to_get = 'http://google.ru'
prox.new_har()
driver.get(url_to_get)
for ent in prox.har['log']['entries']:
print ent['request']['url']
driver.quit()
prox.close()
此示例返回5個http請求。
但是,如果我改變url_to_get到的「https:// ...」,我只能看到3 http請求,並沒有HTTPS請求
有誰知道如何捕捉HTTPS標頭嗎?
在同一臺主機上browsermob服務器作爲測試網站? – sergzach
這是一段非常長的時間...! :)但是,不,browserMob代理沒有從應用程序服務器運行。自那時起,硒就進行了一些修改。所以你的里程可能有所不同 –
我只是嘗試瞭解代理服務器是否可以通過在同一臺服務器上安裝並通過將其附加到https(在nginx的幫助下使用有關證書密鑰的信息)來轉向https。 – sergzach