我需要使用Selenium Chrome驱动程序和browsermob代理获取POST请求的响应正文内容。目前,当我阅读该内容时,该内容未包含在我的文件HAR输出中,尽管我可以在浏览器网络流量中看到响应。我怎样才能让它捕捉到响应流量?(抱歉,编程新手,看不到BMP的python文档)
server.start() proxy = server.create_proxy() chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy)) driver = 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) with open("haroutput.har", "w") as harfile: harfile.write(result_har) server.stop() driver.quit()
您可以在中获取请求和响应代理.har['log']['entries']
相关问题 更多 >
编程相关推荐