Skip to content

Instantly share code, notes, and snippets.

@sljeff
Created April 12, 2023 09:06
Show Gist options
  • Save sljeff/946daef3e98c0224ee2ae6a3d60043ea to your computer and use it in GitHub Desktop.
Save sljeff/946daef3e98c0224ee2ae6a3d60043ea to your computer and use it in GitHub Desktop.
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