Миша, спустя полгода я таки добрался до тасок с участием браузермоб-прокси. Пробую твой код из http://poliarush.com/working/development/chromedriver-python-browsermob-proxy.html (хром+питон). Возвращает пустой har...
>>> profile = webdriver.FirefoxProfile()
>>> profile.set_proxy(proxy.selenium_proxy())
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
profile.set_proxy(proxy.selenium_proxy())
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 225, in set_proxy
self._set_manual_proxy_preference("http", proxy.http_proxy)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 245, in _set_manual_proxy_preference
self.set_preference("network.proxy.%s_port" % key, int(host_details[2]))
IndexError: list index out of range
from browsermobproxy import Server
server = Server("path/to/browsermob-proxy")
server.start()
proxy = server.create_proxy()
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)
proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob
server.stop()
driver.quit()
на шаге:
>>> profile.set_proxy(proxy.selenium_proxy())
получаю ошибку:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
profile.set_proxy(proxy.selenium_proxy())
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 225, in set_proxy
self._set_manual_proxy_preference("http", proxy.http_proxy)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_profile.py", line 245, in _set_manual_proxy_preference
self.set_preference("network.proxy.%s_port" % key, int(host_details[2]))
IndexError: list index out of range