mirror of https://github.com/CIRCL/lookyloo
new: get capture info API call
parent
3d2c7420a4
commit
c52509614e
|
@ -324,6 +324,13 @@ class Lookyloo():
|
||||||
ct = self.get_crawled_tree(capture_uuid)
|
ct = self.get_crawled_tree(capture_uuid)
|
||||||
return ct.root_hartree.stats
|
return ct.root_hartree.stats
|
||||||
|
|
||||||
|
def get_info(self, capture_uuid: str, /) -> Dict[str, Any]:
|
||||||
|
'''Get basic information about the capture.'''
|
||||||
|
ct = self.get_crawled_tree(capture_uuid)
|
||||||
|
to_return = {'url': ct.root_url, 'title': ct.root_hartree.har.initial_title,
|
||||||
|
'capture_time': ct.start_time.isoformat(), 'user_agent': ct.user_agent}
|
||||||
|
return to_return
|
||||||
|
|
||||||
def get_meta(self, capture_uuid: str, /) -> Dict[str, str]:
|
def get_meta(self, capture_uuid: str, /) -> Dict[str, str]:
|
||||||
'''Get the meta informations from a capture (mostly, details about the User Agent used.)'''
|
'''Get the meta informations from a capture (mostly, details about the User Agent used.)'''
|
||||||
capture_dir = self._get_capture_dir(capture_uuid)
|
capture_dir = self._get_capture_dir(capture_uuid)
|
||||||
|
|
|
@ -550,6 +550,7 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None):
|
||||||
ct = lookyloo.get_crawled_tree(tree_uuid)
|
ct = lookyloo.get_crawled_tree(tree_uuid)
|
||||||
b64_thumbnail = lookyloo.get_screenshot_thumbnail(tree_uuid, for_datauri=True)
|
b64_thumbnail = lookyloo.get_screenshot_thumbnail(tree_uuid, for_datauri=True)
|
||||||
screenshot_size = lookyloo.get_screenshot(tree_uuid).getbuffer().nbytes
|
screenshot_size = lookyloo.get_screenshot(tree_uuid).getbuffer().nbytes
|
||||||
|
info = lookyloo.get_info(tree_uuid)
|
||||||
meta = lookyloo.get_meta(tree_uuid)
|
meta = lookyloo.get_meta(tree_uuid)
|
||||||
hostnode_to_highlight = None
|
hostnode_to_highlight = None
|
||||||
if node_uuid:
|
if node_uuid:
|
||||||
|
@ -567,8 +568,7 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None):
|
||||||
print(e)
|
print(e)
|
||||||
pass
|
pass
|
||||||
return render_template('tree.html', tree_json=ct.to_json(),
|
return render_template('tree.html', tree_json=ct.to_json(),
|
||||||
start_time=ct.start_time.isoformat(),
|
info=info,
|
||||||
user_agent=ct.user_agent, root_url=ct.root_url,
|
|
||||||
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
|
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
|
||||||
screenshot_thumbnail=b64_thumbnail, page_title=cache.title,
|
screenshot_thumbnail=b64_thumbnail, page_title=cache.title,
|
||||||
screenshot_size=screenshot_size,
|
screenshot_size=screenshot_size,
|
||||||
|
|
|
@ -246,6 +246,14 @@ class CaptureStats(Resource):
|
||||||
return lookyloo.get_statistics(capture_uuid)
|
return lookyloo.get_statistics(capture_uuid)
|
||||||
|
|
||||||
|
|
||||||
|
@api.route('/json/<string:capture_uuid>/info')
|
||||||
|
@api.doc(description='Get basic information about the capture.',
|
||||||
|
params={'capture_uuid': 'The UUID of the capture'})
|
||||||
|
class CaptureInfo(Resource):
|
||||||
|
def get(self, capture_uuid: str):
|
||||||
|
return lookyloo.get_info(capture_uuid)
|
||||||
|
|
||||||
|
|
||||||
@api.route('/json/<string:capture_uuid>/cookies')
|
@api.route('/json/<string:capture_uuid>/cookies')
|
||||||
@api.doc(description='Get the complete cookie jar created during the capture.',
|
@api.doc(description='Get the complete cookie jar created during the capture.',
|
||||||
params={'capture_uuid': 'The UUID of the capture'})
|
params={'capture_uuid': 'The UUID of the capture'})
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
{% from 'bootstrap/utils.html' import render_messages %}
|
{% from 'bootstrap/utils.html' import render_messages %}
|
||||||
{% from "macros.html" import shorten_string %}
|
{% from "macros.html" import shorten_string %}
|
||||||
|
|
||||||
{% block title %}Capture of {{root_url}}{% endblock %}
|
{% block title %}Capture of {{info['url']}}{% endblock %}
|
||||||
|
|
||||||
{% block card %}
|
{% block card %}
|
||||||
<meta property="og:title" content="Lookyloo capture" />
|
<meta property="og:title" content="Lookyloo capture" />
|
||||||
<meta property="og:type" content="website"/>
|
<meta property="og:type" content="website"/>
|
||||||
<meta
|
<meta
|
||||||
property="og:description"
|
property="og:description"
|
||||||
content="URL captured: {{root_url}}"
|
content="URL captured: {{info['url']}}"
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
property="og:image"
|
property="og:image"
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
var enable_bookmark = {{ enable_bookmark|tojson }};
|
var enable_bookmark = {{ enable_bookmark|tojson }};
|
||||||
var treeData = {{ tree_json | safe }};
|
var treeData = {{ tree_json | safe }};
|
||||||
var parent_uuid = {{ parent_uuid|tojson }};
|
var parent_uuid = {{ parent_uuid|tojson }};
|
||||||
var capture_starttime = new Date(Date.parse("{{ start_time }}"));
|
var capture_starttime = new Date(Date.parse("{{ info['capture_time'] }}"));
|
||||||
window.addEventListener('DOMContentLoaded', (event) => {
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
document.getElementById("start_time").innerHTML =
|
document.getElementById("start_time").innerHTML =
|
||||||
`${capture_starttime.getFullYear()}-${("0" + (capture_starttime.getMonth() + 1)).slice(-2)}-${("0" + capture_starttime.getDate()).slice(-2)} ${capture_starttime.toLocaleTimeString()}`;
|
`${capture_starttime.getFullYear()}-${("0" + (capture_starttime.getMonth() + 1)).slice(-2)}-${("0" + capture_starttime.getDate()).slice(-2)} ${capture_starttime.toLocaleTimeString()}`;
|
||||||
|
@ -342,16 +342,16 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-sm-2">URL captured</dt>
|
<dt class="col-sm-2">URL captured</dt>
|
||||||
<dd class="col-sm-10">{{ shorten_string(root_url, 1000) }}</dd>
|
<dd class="col-sm-10">{{ shorten_string(info['url'], 1000) }}</dd>
|
||||||
|
|
||||||
<dt class="col-sm-2">Page title</dt>
|
<dt class="col-sm-2">Page title</dt>
|
||||||
<dd class="col-sm-10">{{ page_title }}</dd>
|
<dd class="col-sm-10">{{ info['title'] }}</dd>
|
||||||
|
|
||||||
<dt class="col-sm-2">Capture time</dt>
|
<dt class="col-sm-2">Capture time</dt>
|
||||||
<dd class="col-sm-10" id="start_time"></dd>
|
<dd class="col-sm-10" id="start_time"></dd>
|
||||||
|
|
||||||
<dt class="col-sm-2">User Agent</dt>
|
<dt class="col-sm-2">User Agent</dt>
|
||||||
<dd class="col-sm-10">{{ user_agent }}</dd>
|
<dd class="col-sm-10">{{ info['user_agent'] }}</dd>
|
||||||
|
|
||||||
{% if meta %}
|
{% if meta %}
|
||||||
{% for k, v in meta.items() if k not in ['user_agent'] %}
|
{% for k, v in meta.items() if k not in ['user_agent'] %}
|
||||||
|
|
Loading…
Reference in New Issue