phantomfetch 0.4.6__tar.gz → 0.4.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: phantomfetch
3
- Version: 0.4.6
3
+ Version: 0.4.7
4
4
  Summary: High-performance agentic web scraping library combining curl-cffi speed with Playwright browser capabilities
5
5
  Keywords: web-scraping,playwright,curl-cffi,async,browser-automation,http-client,agentic,anti-detection
6
6
  Author: CosmicBull
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "phantomfetch"
3
- version = "0.4.6"
3
+ version = "0.4.7"
4
4
  description = "High-performance agentic web scraping library combining curl-cffi speed with Playwright browser capabilities"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -72,6 +72,7 @@ class CDPEngine:
72
72
  fingerprint_options: dict[str, Any] | None = None,
73
73
  launch_args: list[str] | None = None,
74
74
  browser_type: str = "chromium",
75
+ cdp_connection_type: str = "cdp",
75
76
  ):
76
77
  """
77
78
  Args:
@@ -93,6 +94,10 @@ class CDPEngine:
93
94
  --disable-blink-features=AutomationControlled are always
94
95
  included automatically.
95
96
  browser_type: Which Playwright browser engine to use: "chromium", "firefox", or "webkit"
97
+ cdp_connection_type: Connection protocol to use: "cdp" for raw DevTools Protocol
98
+ (connect_over_cdp) or "playwright" for Playwright wire protocol (connect).
99
+ Defaults to "cdp". Use "playwright" for services like
100
+ playwright run-server or Scrapeless recording.
96
101
  """
97
102
  self.cdp_endpoint = cdp_endpoint
98
103
  self.headless = headless
@@ -105,6 +110,7 @@ class CDPEngine:
105
110
  self.fingerprint_options = fingerprint_options or {}
106
111
  self.launch_args = launch_args or []
107
112
  self.browser_type = browser_type
113
+ self.cdp_connection_type = cdp_connection_type
108
114
 
109
115
  # Map playwright browser type to BrowserForge constraint
110
116
  if "browser" not in self.fingerprint_options and self.browser_type in (
@@ -144,9 +150,17 @@ class CDPEngine:
144
150
  self._playwright = await async_playwright().start()
145
151
  try:
146
152
  if self.cdp_endpoint:
147
- logger.info(f"[cdp] Connecting to: {self.cdp_endpoint}")
153
+ logger.info(
154
+ f"[cdp] Connecting to: {self.cdp_endpoint} (type={self.cdp_connection_type})"
155
+ )
148
156
  browser_obj = getattr(self._playwright, self.browser_type)
149
- self._browser = await browser_obj.connect_over_cdp(self.cdp_endpoint)
157
+
158
+ if self.cdp_connection_type == "playwright":
159
+ self._browser = await browser_obj.connect(self.cdp_endpoint)
160
+ else:
161
+ self._browser = await browser_obj.connect_over_cdp(
162
+ self.cdp_endpoint
163
+ )
150
164
 
151
165
  if self.use_existing_page and self._browser.contexts:
152
166
  self._existing_context = self._browser.contexts[0]
File without changes