I am using browsermobproxy to store xhr requests with selenium webdriver and python.
proxy.new_har("req", options={'captureHeaders': True,'captureContent':True})
driver.get("http://www.example.com")
proxy.har
After reading the har file, I find entries
to be null dictionary. Do I have to explicitly write data in the har file? If yes, then how? I wrote this in the end of my python file so as to write everything in the har file. But am I missing some step in between where explicit modification in the har file is to be made using proxy?
har_data = json.dumps(proxy.har, indent=4)
save_har = open("req.har", 'a')
This is what my har file looks like:
"log": {
"comment": "",
"entries": [],
"version": "1.2",
"pages": [
{
"pageTimings": {
"comment": ""
},
"comment": "",
"title": "requirements",
"id": "requirements",
"startedDateTime": "2016-01-08T11:48:01.477+05:30"
}
],
"creator": {
"comment": "",
"version": "2.1.0-beta-4-littleproxy",
"name": "BrowserMob Proxy"
}
result = json.dumps(self.proxy.har, ensure_ascii=False)
har_file = open('newfile' + '.har', 'w')
har_file.write(str(result))
har_file.close()
This works for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.