2013-08-06 18 views

risposta

3

Sì, utilizzando BrowsermobProxy è possibile generare file HAR utilizzando chromedriver.

Ecco uno script in python per generare in modo programmatico file HAR utilizzando Selenium, BrowserMob Proxy e chromedriver. Per eseguire questo script sono necessari pacchetti Python per selenio e browser-proxy.

from browsermobproxy import Server 
from selenium import webdriver 
import os 
import json 
import urlparse 

server = Server("path/to/browsermob-proxy") 
server.start() 
proxy = server.create_proxy() 

chromedriver = "path/to/chromedriver" 
os.environ["webdriver.chrome.driver"] = chromedriver 
url = urlparse.urlparse (proxy.proxy).path 
chrome_options = webdriver.ChromeOptions() 
chrome_options.add_argument("--proxy-server={0}".format(url)) 
driver = webdriver.Chrome(chromedriver,chrome_options =chrome_options) 
proxy.new_har("http://stackoverflow.com", options={'captureHeaders': True}) 
driver.get("http://stackoverflow.com")  
result = json.dumps(proxy.har, ensure_ascii=False) 
print result 
proxy.stop()  
driver.quit() 
+1

È possibile controllare come soluzione completa: [speedprofile] (https://github.com/parasdahal/profileprofilo) –

0

È possibile abilitare il registro delle prestazioni tramite chromedriver e analizzare il traffico di rete per creare HAR da soli.