adding new extract command to extract selector or main content as markdown, updateing version as 0.5.0
This commit is contained in:
@@ -247,6 +247,9 @@ class BrowserCLI:
|
||||
def extract_json(self, selector: str):
|
||||
return self._cmd("extract.json", {"selector": selector})
|
||||
|
||||
def extract_markdown(self, selector: str | None = None) -> str:
|
||||
return self._cmd("extract.markdown", {"selector": selector}) or ""
|
||||
|
||||
# ── Session ───────────────────────────────────────────────────────────
|
||||
|
||||
def session_save(self, name: str) -> None:
|
||||
|
||||
@@ -73,3 +73,11 @@ def extract_html():
|
||||
"""Print the full HTML of the active tab to stdout."""
|
||||
html = _handle("extract.html")
|
||||
click.echo(html or "")
|
||||
|
||||
|
||||
@extract_group.command("markdown")
|
||||
@click.option("--selector", help="Extract only the DOM subtree matching this CSS selector.")
|
||||
def extract_markdown(selector):
|
||||
"""Extract the page's main content as Markdown."""
|
||||
markdown = _handle("extract.markdown", {"selector": selector})
|
||||
click.echo(markdown or "", nl=not (markdown or "").endswith("\n"))
|
||||
|
||||
Reference in New Issue
Block a user