Create a har file with xhr request only in chrome dev tools

后端 未结 1 1355
轻奢々
轻奢々 2020-12-18 15:39

Is there a way to create a har file with xhr request only in chrome dev tools?

Even though I can filter the requests in dev tools, when I s

1条回答
  •  时光说笑
    2020-12-18 16:19

    Seems like there is no direct way to filter the requests. What I did was, creating the har file with all the requests and filter that file, then save it again after removing unwanted requests.

    There is a entry called entries in the content inside har file. It contains all the requests we have sent in an array. I got the har file content and filtered it using JSONPath expressions.

    About JSONPath, JSONPAth evaluator

    Expression to filter application/json types : $..entries[?(@.response.content.mimeType == "application/json")]

    After that I have replaced the entries array with the one I have filtered in the har file and saved it again. This way you can get a har file with filtered requests. Same way you can filter XHR or any other types using the relevant JSONPath expression

    0 讨论(0)
提交回复
热议问题