dp-cli 0.1.0__tar.gz → 0.1.1__tar.gz

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.
Files changed (30) hide show
  1. {dp_cli-0.1.0 → dp_cli-0.1.1}/PKG-INFO +1 -1
  2. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/session.py +17 -0
  3. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli.egg-info/PKG-INFO +1 -1
  4. {dp_cli-0.1.0 → dp_cli-0.1.1}/pyproject.toml +1 -1
  5. {dp_cli-0.1.0 → dp_cli-0.1.1}/README.md +0 -0
  6. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/__init__.py +0 -0
  7. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/__init__.py +0 -0
  8. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/_utils.py +0 -0
  9. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/browser.py +0 -0
  10. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/element.py +0 -0
  11. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/keyboard.py +0 -0
  12. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/misc.py +0 -0
  13. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/network.py +0 -0
  14. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/page.py +0 -0
  15. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/snapshot_cmd.py +0 -0
  16. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/storage.py +0 -0
  17. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/commands/tab.py +0 -0
  18. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/main.py +0 -0
  19. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/output.py +0 -0
  20. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/snapshot/__init__.py +0 -0
  21. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/snapshot/a11y.py +0 -0
  22. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/snapshot/extract.py +0 -0
  23. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/snapshot/js_scripts.py +0 -0
  24. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli/snapshot/utils.py +0 -0
  25. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli.egg-info/SOURCES.txt +0 -0
  26. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli.egg-info/dependency_links.txt +0 -0
  27. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli.egg-info/entry_points.txt +0 -0
  28. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli.egg-info/requires.txt +0 -0
  29. {dp_cli-0.1.0 → dp_cli-0.1.1}/dp_cli.egg-info/top_level.txt +0 -0
  30. {dp_cli-0.1.0 → dp_cli-0.1.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dp-cli
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A powerful CLI for DrissionPage — browser automation, structured data extraction, network listening and more.
5
5
  License: BSD-3-Clause
6
6
  Project-URL: Homepage, https://github.com/mofanx/dp-cli
@@ -63,6 +63,16 @@ def list_sessions() -> list:
63
63
  return sessions
64
64
 
65
65
 
66
+ def _detect_headless(port: int) -> bool:
67
+ """通过 /json/version 探测浏览器是否 headless 模式"""
68
+ try:
69
+ import requests
70
+ resp = requests.get(f'http://127.0.0.1:{port}/json/version', timeout=3)
71
+ return 'headless' in resp.json().get('User-Agent', '').lower()
72
+ except Exception:
73
+ return False
74
+
75
+
66
76
  def get_browser(session_name: str = 'default', headless: bool = False,
67
77
  browser_path: str = None, user_data_dir: str = None,
68
78
  proxy: str = None, port: int = None):
@@ -82,6 +92,10 @@ def get_browser(session_name: str = 'default', headless: bool = False,
82
92
  co = ChromiumOptions(read_file=False)
83
93
  co.set_local_port(port)
84
94
  co.existing_only(True)
95
+ # 探测浏览器 headless 状态,同步到 options,避免 DrissionPage
96
+ # 因 headless 不匹配执行 quit→restart 导致无头浏览器被关闭
97
+ if _detect_headless(port):
98
+ co.headless(True)
85
99
  try:
86
100
  page = ChromiumPage(co)
87
101
  except Exception as e:
@@ -110,6 +124,9 @@ def get_browser(session_name: str = 'default', headless: bool = False,
110
124
  co = ChromiumOptions(read_file=False)
111
125
  co.set_local_port(saved_port)
112
126
  co.existing_only(True)
127
+ # 同步 headless 状态(同情况1)
128
+ if _detect_headless(saved_port):
129
+ co.headless(True)
113
130
  page = ChromiumPage(co)
114
131
  return page
115
132
  except Exception:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dp-cli
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: A powerful CLI for DrissionPage — browser automation, structured data extraction, network listening and more.
5
5
  License: BSD-3-Clause
6
6
  Project-URL: Homepage, https://github.com/mofanx/dp-cli
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dp-cli"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "A powerful CLI for DrissionPage — browser automation, structured data extraction, network listening and more."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes