Skip to content

Commit

Permalink
new: Support headed capture, add push call
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Feb 7, 2025
1 parent f865099 commit bda9f45
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 51 deletions.
92 changes: 43 additions & 49 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pylacus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CaptureSettings(TypedDict, total=False):
referer: str | None
with_favicon: bool
allow_tracking: bool
headless: bool

force: bool | None
recapture_interval: int | None
Expand Down Expand Up @@ -157,6 +158,7 @@ def enqueue(self, *,
referer: str | None=None,
with_favicon: bool=False,
allow_tracking: bool=False,
headless: bool=True,
rendered_hostname_only: bool=True,
force: bool=False,
recapture_interval: int=300,
Expand Down Expand Up @@ -187,6 +189,7 @@ def enqueue(self, *,
referer: str | None=None,
with_favicon: bool=False,
allow_tracking: bool=False,
headless: bool=True,
rendered_hostname_only: bool=True,
force: bool=False,
recapture_interval: int=300,
Expand All @@ -201,6 +204,7 @@ def enqueue(self, *,
else:
to_enqueue = {'depth': depth, 'java_script_enabled': java_script_enabled,
'with_favicon': with_favicon, 'allow_tracking': allow_tracking,
'headless': headless,
'rendered_hostname_only': rendered_hostname_only,
'force': force, 'recapture_interval': recapture_interval, 'priority': priority}
if url:
Expand Down Expand Up @@ -278,6 +282,16 @@ def get_capture(self, uuid: str, *, decode: bool=True) -> CaptureResponse | Capt
return response
return self._decode_response(response)

def push_capture(self, uuid: str, push_to: str) -> dict[str, Any]:
'''Push the capture to a specific endpoint.
:param uuid: UUID of the capture to push (in the lacus instance you are querying).
:param push_to: Endpoint to push the results of the capture to.
'''
results = self.get_capture(uuid, decode=False)
response = requests.post(push_to, json=results)
return response.json()

# # Stats and status of the lacus instance

def daily_stats(self, d: str | date | datetime | None=None, /, *, cardinality_only: bool=True) -> dict[str, Any]:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ classifiers = [
pylacus = 'pylacus:main'

[project.optional-dependencies]
docs = ["Sphinx (>=8) ; python_version >= '3.10'"]
docs = ["Sphinx (>=8.1.3) ; python_version >= \"3.10\""]

[tool.poetry.group.dev.dependencies]
mypy = "^1.14.1"
mypy = "^1.15.0"
types-requests = "^2.32.0.20241016"
pytest = "^8.3.4"

Expand Down

0 comments on commit bda9f45

Please sign in to comment.