我需要使用 Selenium Chrome 驱动程序和 browsermob 代理获取 POST 请求的响应正文内容。目前,当我阅读它时,此内容不包含在我的文件 HAR 输出中,尽管我可以在浏览器网络流量中看到响应。我怎样才能让它捕获响应流量?(很抱歉编程新手,看不到太多 BMP 的 python 文档)
server.start() 代理 = server.create_proxy() chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy)) 驱动程序 = webdriver.Chrome(executable_path="chromedriver.exe", chrome_options=chrome_options) proxy.new_har("req", options={'captureHeaders': True,'captureContent':True}) driver.get('https://www.example.com/something') result_har = json.dumps(proxy.har, ensure_ascii=False) 使用 open("haroutput.har", "w") 作为 harfile: harfile.write(result_har) server.stop() driver.quit()