new: Add calls to get screenshot, html, cookies, and complete capture.

pull/79/head
Raphaël Vinot 2020-06-29 19:02:57 +02:00
parent c2fd7c8280
commit f480db2103
1 changed files with 18 additions and 1 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Optional, Dict, Any from io import BytesIO, StringIO
from typing import Optional, Dict, Any, List
from urllib.parse import urljoin from urllib.parse import urljoin
from pathlib import Path from pathlib import Path
@ -43,3 +44,19 @@ class Lookyloo():
def get_redirects(self, capture_uuid: str) -> Dict[str, Any]: def get_redirects(self, capture_uuid: str) -> Dict[str, Any]:
r = self.session.get(urljoin(self.root_url, str(Path('json', capture_uuid, 'redirects')))) r = self.session.get(urljoin(self.root_url, str(Path('json', capture_uuid, 'redirects'))))
return r.json() return r.json()
def get_screenshot(self, capture_uuid: str) -> BytesIO:
r = self.session.get(urljoin(self.root_url, str(Path('tree', capture_uuid, 'image'))))
return BytesIO(r.content)
def get_cookies(self, capture_uuid: str) -> List[Dict[str, str]]:
r = self.session.get(urljoin(self.root_url, str(Path('tree', capture_uuid, 'cookies'))))
return r.json()
def get_html(self, capture_uuid: str) -> StringIO:
r = self.session.get(urljoin(self.root_url, str(Path('tree', capture_uuid, 'html'))))
return StringIO(r.text)
def get_complete_capture(self, capture_uuid: str) -> BytesIO:
r = self.session.get(urljoin(self.root_url, str(Path('tree', capture_uuid, 'export'))))
return BytesIO(r.content)