browsermob-proxy
browsermob-proxy copied to clipboard
Can`t get response body in HAR, Browsermobproxy + selenium + Chrome in Python
the stackoverflow link : https://stackoverflow.com/questions/49832373/cant-get-response-body-in-har-browsermobproxy-selenium-firefox-in-python
I've answer the question on stackoverflow but i'll repeat it here:
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)
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)