1

enter image description here

I'm working with a website using chrome. I want to grab only the responses to certain requests (which I am filtering for in the screenshot). Previously I tried to Export all http requests on a specific page to txt/csv , so I see that you can get a har file with a lot of unneeded info, but I would like just grab just the resonse bodies. Is this possible using devtools or an extension?

user1592380
  • 34,265
  • 92
  • 284
  • 515

1 Answers1

3
const re = /\/stackoverflow/
const result = HAR.log.entries.filter(entiry => re.test(entiry.request.url))
console.log(result)

That's all you need. HAR - your data with

a lot of unneeded info

re - your filter

Note the / in the regexp. The filter in the DevTools doesn't take the domain into account.

x00
  • 13,643
  • 3
  • 16
  • 40
  • Sorry for my ignorance, but where do you run this code. Somehow within devtools or after export of the larger HAR file? – user1592380 Oct 09 '21 at 15:17
  • You can 1) export har-file, 2) open it with a text-editor, 3) copy it's content, 4) write in the devtools console `HAR = ` 5) paste the content of har-file copied earlier, press (that will create a HAR object in the console) 6) copy&paste the above code in the console 7) run it. But if you know JS/node.js it's preferably to open exported HAR in a node.js script – x00 Oct 09 '21 at 17:12