import json
from collections import defaultdict
def deduplicate_http_responses(response_list):
"""
Deduplicates a list of HTTP response records.
Args:
response_list (list): A list of dictionaries, where each dictionary
represents an HTTP response record.
Returns:
list: A new list containing only the unique HTTP response records.
"""
seen = set() # Use a set to track seen responses
unique_responses = []
for response in response_list:
# Convert the response to a tuple of its key fields for hashing
# You can customize these keys based on what defines a duplicate
response_tuple = tuple(response.get("url", "") + "," + response.get("method", "") + "," + response.get("status_code", ""))
if response_tuple not in seen:
unique_responses.append(response)
seen.add(response_tuple)
return unique_responses
Add your comment