MCPcopy Create free account
hub / github.com/Integuru-AI/Integuru / get_har_urls

Function get_har_urls

integuru/util/har_processing.py:132–213  ·  view source on GitHub ↗

Extracts and returns a list of tuples containing method, URL, response format, and response preview from a HAR file, excluding certain file types and keywords.

(har_file_path: str)

Source from the content-addressed store, hash-verified

130
131
132def get_har_urls(har_file_path: str) -> List[Tuple[str, str, str, str]]:
133 """
134 Extracts and returns a list of tuples containing method, URL, response format, and response preview
135 from a HAR file, excluding certain file types and keywords.
136 """
137 # List to store tuples of URLs, request methods, response file formats, and response preview
138 urls_with_details = []
139
140 # Define a tuple of file extensions to exclude
141 excluded_extensions = (
142 ".png",
143 ".jpg",
144 ".jpeg",
145 ".gif",
146 ".webp",
147 ".svg",
148 ".ico", # Image files
149 ".css", # Stylesheets
150 # ".js",
151 # ".map", # JavaScript files
152 ".woff",
153 ".woff2",
154 ".ttf",
155 ".otf",
156 ".eot", # Font files
157 ".mp3",
158 ".mp4",
159 ".wav",
160 ".avi",
161 ".mov",
162 ".flv",
163 ".wmv",
164 ".webm", # Media files
165 # ".pdf",
166 # ".zip",
167 ".rar",
168 ".7z",
169 ".tar",
170 ".gz",
171 ".exe",
172 ".dmg", # Other non-text files
173 )
174
175 # Read the HAR file
176 with open(har_file_path, "r", encoding="utf-8") as file:
177 har_data = json.load(file)
178
179 # Extract entries from the HAR data
180 entries = har_data.get("log", {}).get("entries", [])
181 for entry in entries:
182 request = entry.get("request", {})
183 response = entry.get("response", {})
184 url = request.get("url")
185 method = request.get("method", "GET") # Default to 'GET' if method is missing
186 response_format = response.get("content", {}).get("mimeType", "")
187 response_text = response.get("content", {}).get("text", "")
188 response_preview = response_text[:30] if response_text else ""
189

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected