Created
April 12, 2023 09:06
-
-
Save sljeff/946daef3e98c0224ee2ae6a3d60043ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
def filter(har_file, contains): | |
with open(har_file) as f: | |
har = json.load(f) | |
entries = har['log']['entries'] | |
filtered = [e for e in entries if contains in e['request']['url']] | |
har['log']['entries'] = filtered | |
return har | |
def main(): | |
har_file = sys.argv[1] | |
contains = sys.argv[2] | |
filtered_har = sys.argv[3] | |
har = filter(har_file, contains) | |
with open(filtered_har, 'w') as f: | |
# json.dump(har, f, indent=4) | |
json.dump(har, f) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment