38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
import json
|
|
|
|
def main():
|
|
"""
|
|
Opens a HAR archive file "data.har" and prints a list of files (URLs)
|
|
found in the archive.
|
|
"""
|
|
har_file_path = "data.har"
|
|
with open(har_file_path, 'r', encoding='utf-8') as f:
|
|
har_data = json.load(f)
|
|
|
|
entries = har_data.get('log', {}).get('entries', [])
|
|
if not entries:
|
|
print("No entries found in the HAR file.")
|
|
return
|
|
|
|
print("Files found in the HAR archive:")
|
|
for entry in entries:
|
|
response = entry.get('response', {})
|
|
content = response.get('content', {})
|
|
mime_type = content.get('mimeType', '')
|
|
|
|
if not mime_type.startswith('image/'):
|
|
continue
|
|
|
|
request = entry.get('request', {})
|
|
url = request.get('url')
|
|
if url:
|
|
print(url)
|
|
else:
|
|
# This case might be less likely if we are filtering by mimeType,
|
|
# but kept for robustness if an image entry somehow lacks a URL.
|
|
print("Image entry found with no request URL.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|