2
from selenium import web driver
from browsermobproxy import Server
from selenium.webdriver.common.by import By
import json
import time


server = Server(r'D:\browsermob-proxy-2.1.4\bin\browsermob-proxy.bat')
server.start()
proxy = server.create_proxy({'captureHeaders': True, 'captureContent': True, 'captureBinaryContent': True})
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)

proxy.new_har('xxx')
driver.get('XXX')
proxy.wait_for_traffic_to_stop(1, 60)

This is all I get:

enter image description here

I want to get the response from the body but failed, are there any arguments I need to set?

Sebastian Speitel
  • 6,351
  • 2
  • 16
  • 34
chbr
  • 21
  • 1

1 Answers1

1

I've lost some time searching for a solution to this problem.

Move the captureHeaders and other options from the create_proxy() call to new_har(). Like this:

from selenium import web driver
from browsermobproxy import Server
from selenium.webdriver.common.by import By
import json
import time


server = Server(r'D:\browsermob-proxy-2.1.4\bin\browsermob-proxy.bat')
server.start()
proxy = server.create_proxy()
profile = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)

proxy.new_har('xxx', options={'captureHeaders': True, 'captureContent': True, 'captureBinaryContent': True})
driver.get('XXX')
proxy.wait_for_traffic_to_stop(1, 60)