pylookyloo 1.27.0__py3-none-any.whl → 1.28.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pylookyloo might be problematic. Click here for more details.
- pylookyloo/api.py +38 -1
- {pylookyloo-1.27.0.dist-info → pylookyloo-1.28.0.dist-info}/METADATA +3 -1
- pylookyloo-1.28.0.dist-info/RECORD +8 -0
- {pylookyloo-1.27.0.dist-info → pylookyloo-1.28.0.dist-info}/WHEEL +1 -1
- pylookyloo-1.27.0.dist-info/RECORD +0 -8
- {pylookyloo-1.27.0.dist-info → pylookyloo-1.28.0.dist-info}/LICENSE +0 -0
- {pylookyloo-1.27.0.dist-info → pylookyloo-1.28.0.dist-info}/entry_points.txt +0 -0
pylookyloo/api.py
CHANGED
|
@@ -17,6 +17,29 @@ import requests
|
|
|
17
17
|
|
|
18
18
|
from urllib3.util import Retry
|
|
19
19
|
from requests.adapters import HTTPAdapter
|
|
20
|
+
from requests.sessions import Session
|
|
21
|
+
from requests.status_codes import codes
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class SafeRedirectRePOSTSession(Session):
|
|
25
|
+
|
|
26
|
+
def rebuild_method(self, prepared_request: requests.PreparedRequest, response: requests.Response) -> None:
|
|
27
|
+
# This method will resubmit a POST when we have a http -> https redirect
|
|
28
|
+
if response.status_code == codes.moved and prepared_request.method == 'POST':
|
|
29
|
+
# make sure it is just a redirect http->https and we're not going to a different host
|
|
30
|
+
prec_url = urlparse(response.url)
|
|
31
|
+
next_url = urlparse(prepared_request.url)
|
|
32
|
+
|
|
33
|
+
if (prec_url.netloc != next_url.netloc or prec_url.scheme != 'http'
|
|
34
|
+
or next_url.scheme != 'https'):
|
|
35
|
+
super().rebuild_method(prepared_request, response)
|
|
36
|
+
else:
|
|
37
|
+
# For surely good reasons, requests force-remove the body of the redirected requests unless the statuscode is either 307 or 308
|
|
38
|
+
# https://github.com/psf/requests/issues/1084
|
|
39
|
+
# Doing that makes sure we keep it
|
|
40
|
+
response.status_code = 307
|
|
41
|
+
else:
|
|
42
|
+
super().rebuild_method(prepared_request, response)
|
|
20
43
|
|
|
21
44
|
|
|
22
45
|
class PyLookylooError(Exception):
|
|
@@ -46,6 +69,7 @@ class CaptureSettings(TypedDict, total=False):
|
|
|
46
69
|
locale: str | None
|
|
47
70
|
color_scheme: str | None
|
|
48
71
|
java_script_enabled: bool
|
|
72
|
+
headless: bool
|
|
49
73
|
viewport: dict[str, int] | None
|
|
50
74
|
referer: str | None
|
|
51
75
|
|
|
@@ -77,7 +101,7 @@ class Lookyloo():
|
|
|
77
101
|
self.root_url = 'http://' + self.root_url
|
|
78
102
|
if not self.root_url.endswith('/'):
|
|
79
103
|
self.root_url += '/'
|
|
80
|
-
self.session =
|
|
104
|
+
self.session = SafeRedirectRePOSTSession()
|
|
81
105
|
self.session.headers['user-agent'] = useragent if useragent else f'PyLookyloo / {version("pylookyloo")}'
|
|
82
106
|
if proxies:
|
|
83
107
|
self.session.proxies.update(proxies)
|
|
@@ -154,6 +178,7 @@ class Lookyloo():
|
|
|
154
178
|
locale: str | None=None,
|
|
155
179
|
color_scheme: str | None=None,
|
|
156
180
|
java_script_enabled: bool=True,
|
|
181
|
+
headless: bool=True,
|
|
157
182
|
viewport: dict[str, int] | None=None,
|
|
158
183
|
referer: str | None=None,
|
|
159
184
|
listing: bool | None=None,
|
|
@@ -177,6 +202,7 @@ class Lookyloo():
|
|
|
177
202
|
locale: str | None=None,
|
|
178
203
|
color_scheme: str | None=None,
|
|
179
204
|
java_script_enabled: bool | None=None,
|
|
205
|
+
headless: bool=True,
|
|
180
206
|
viewport: dict[str, int] | None=None,
|
|
181
207
|
referer: str | None=None,
|
|
182
208
|
listing: bool | None=None,
|
|
@@ -204,6 +230,7 @@ class Lookyloo():
|
|
|
204
230
|
:param locale: The locale of the browser
|
|
205
231
|
:param color_scheme: The prefered color scheme of the browser (light or dark)
|
|
206
232
|
:param java_script_enabled: If False, no JS will run during the capture.
|
|
233
|
+
:param headless: If False, the browser will be headed, it requires the capture to be done on a desktop.
|
|
207
234
|
:param viewport: The viewport of the browser used for capturing
|
|
208
235
|
:param referer: The referer URL for the capture
|
|
209
236
|
:param listing: If False, the capture will be not be on the publicly accessible index page of lookyloo
|
|
@@ -257,6 +284,8 @@ class Lookyloo():
|
|
|
257
284
|
to_send['color_scheme'] = color_scheme
|
|
258
285
|
if java_script_enabled is not None:
|
|
259
286
|
to_send['java_script_enabled'] = java_script_enabled
|
|
287
|
+
if headless is not None:
|
|
288
|
+
to_send['headless'] = headless
|
|
260
289
|
if viewport:
|
|
261
290
|
to_send['viewport'] = viewport
|
|
262
291
|
if referer:
|
|
@@ -539,6 +568,14 @@ class Lookyloo():
|
|
|
539
568
|
r = self.session.get(url)
|
|
540
569
|
return r.json()
|
|
541
570
|
|
|
571
|
+
def push_from_lacus(self, capture: dict[str, Any]) -> dict[str, Any]:
|
|
572
|
+
'''Push a capture from Lacus to Lookyloo
|
|
573
|
+
|
|
574
|
+
:param capture: The capture to push from Lacus
|
|
575
|
+
'''
|
|
576
|
+
r = self.session.post(urljoin(self.root_url, str(PurePosixPath('json', 'upload'))), json=capture)
|
|
577
|
+
return r.json()
|
|
578
|
+
|
|
542
579
|
@overload
|
|
543
580
|
def upload_capture(self, *, quiet: Literal[True],
|
|
544
581
|
listing: bool = False,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pylookyloo
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.28.0
|
|
4
4
|
Summary: Python CLI and module for Lookyloo
|
|
5
5
|
License: BSD-3-Clause
|
|
6
6
|
Author: Raphaël Vinot
|
|
@@ -22,7 +22,9 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
22
22
|
Classifier: Topic :: Internet
|
|
23
23
|
Classifier: Topic :: Security
|
|
24
24
|
Provides-Extra: docs
|
|
25
|
+
Provides-Extra: examples
|
|
25
26
|
Requires-Dist: Sphinx (>=8.1.3) ; (python_version >= "3.10") and (extra == "docs")
|
|
27
|
+
Requires-Dist: pylacus (>=1.12.1) ; extra == "examples"
|
|
26
28
|
Requires-Dist: requests (>=2.32.3)
|
|
27
29
|
Project-URL: Documentation, https://pylookyloo.readthedocs.io/en/latest/
|
|
28
30
|
Project-URL: Repository, https://github.com/lookyloo/PyLookyloo
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
pylookyloo/__init__.py,sha256=_JYXwXHL7ShZkeruvGd8qDTpxNRfuDjvV65SOMMU6yc,1922
|
|
2
|
+
pylookyloo/api.py,sha256=h6v4hf4HtxUD-pf4uEKSurMw_QYnpcgYUBk3dv7v1Nc,30733
|
|
3
|
+
pylookyloo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
pylookyloo-1.28.0.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
|
|
5
|
+
pylookyloo-1.28.0.dist-info/METADATA,sha256=mG1xvmCC10QP-yBYZ4PkfI8NVLiZe9f8HOAHLeydKrY,2347
|
|
6
|
+
pylookyloo-1.28.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
7
|
+
pylookyloo-1.28.0.dist-info/entry_points.txt,sha256=y2c0Ujg8co6Xyf7MoxStVU-fLQMZBSGAg-KFidmsha4,44
|
|
8
|
+
pylookyloo-1.28.0.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
pylookyloo/__init__.py,sha256=_JYXwXHL7ShZkeruvGd8qDTpxNRfuDjvV65SOMMU6yc,1922
|
|
2
|
-
pylookyloo/api.py,sha256=b9pzLGap2hCMZgdmOQ4-9JErU6aTTF4WQPJih24BoxU,28921
|
|
3
|
-
pylookyloo/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
pylookyloo-1.27.0.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
|
|
5
|
-
pylookyloo-1.27.0.dist-info/METADATA,sha256=sTFungmhlKsMWBp6ObbZl4BnUk6cQJe60O0UDHH2-_k,2266
|
|
6
|
-
pylookyloo-1.27.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
|
7
|
-
pylookyloo-1.27.0.dist-info/entry_points.txt,sha256=y2c0Ujg8co6Xyf7MoxStVU-fLQMZBSGAg-KFidmsha4,44
|
|
8
|
-
pylookyloo-1.27.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|