vchrome 0.0.0__py3-none-any.whl → 0.0.2__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.
vchrome/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = '0.0.0'
1
+ __version__ = '0.0.2'
2
2
  __author__ = 'v'
3
3
  # ----------------------------------------------------------------------------------------------------
4
4
  _allowed = {'Chrome'}
@@ -1100,7 +1100,7 @@ def cdp_client(hostname, port, debug=False):
1100
1100
  raise Exception('wait show over time.')
1101
1101
  time.sleep(0.08)
1102
1102
  if pretime:
1103
- time.sleep(pretime) # 组件出现时,可能事件并未挂上去,稍微等待一下
1103
+ time.sleep(pretime) # When the component appears, the event might not have been attached yet. Please wait a moment.
1104
1104
  def drag(self, x=1, y=2, zero='center', button='left', count=1):
1105
1105
  self.wait_show()
1106
1106
  self._set_in_view()
@@ -1162,8 +1162,9 @@ def cdp_client(hostname, port, debug=False):
1162
1162
  self.wait_show()
1163
1163
  if try_use_img and self.className == 'HTMLImageElement':
1164
1164
  try:
1165
- # 如果是 <img> 标签,就尝试通过标签采集,采集不到再走屏幕截图。
1166
- # 因为 img 标签的图片最好接近原生图片,这样效果会更好,当然也可以配置 try_use_img=False 直接关掉这种图片获取方式,就用截图,那样比较统一。
1165
+ # If it’s an <img> tag, try to capture it via the element first; if that fails, fall back to a screenshot.
1166
+ # Images from <img> tags are best captured as native images for better quality.
1167
+ # Of course, you can also set try_use_img=False to disable this method and use screenshots only, which makes the process more uniform.
1167
1168
  src = self['src']
1168
1169
  if src:
1169
1170
  if src.startswith('http'):
@@ -1362,9 +1363,19 @@ def cdp_client(hostname, port, debug=False):
1362
1363
  _trav(snode)
1363
1364
  _trav(rnode)
1364
1365
  return clist
1366
+ def _get_doc_tree(self):
1367
+ start = perf_counter()
1368
+ while True:
1369
+ doc = self.f.cdp('DOM.getDocument', {'depth':-1, 'pierce':True})
1370
+ if 'root' in doc:
1371
+ return doc
1372
+ else:
1373
+ time.sleep(0.1)
1374
+ if perf_counter() - start > 2:
1375
+ break
1365
1376
  def _get_flattened_node(self, nodeId=None):
1366
1377
  if nodeId == None:
1367
- rnode = self.f.cdp('DOM.getDocument', {'depth':-1, 'pierce':True})['root']
1378
+ rnode = self._get_doc_tree()['root']
1368
1379
  else:
1369
1380
  rnode = self.f.cdp('DOM.describeNode', {'nodeId':nodeId, 'depth':-1, 'pierce':True})['node']
1370
1381
  mnodes = {"nodes": self._trav_node_tree(rnode)}
@@ -1961,8 +1972,8 @@ def cdp_client(hostname, port, debug=False):
1961
1972
  # 'sourcePort': 443,
1962
1973
  # 'sourceScheme': 'Secure',
1963
1974
  # 'value': '2826F2D60D5E56C841B9E33F82051E8A'},...]
1964
- # str 作用于当前 url 页面,只能在访问页面后执行。
1965
- # list 是用于完美还原 cookies 状态,可以在访问页面前执行。
1975
+ # A str applies to the current URL page and can only be executed after visiting the page.
1976
+ # A list is used to perfectly restore the cookies state and can be executed before visiting the page.
1966
1977
  raise Exception('cookies must be (str/list/CookieManager)')
1967
1978
  def _get_remote_list(self):
1968
1979
  _self = self
@@ -2196,7 +2207,8 @@ def cdp_client(hostname, port, debug=False):
2196
2207
  else:
2197
2208
  pf = finfo.get('parent')
2198
2209
  if not pf:
2199
- # 初始化阶段,frame 并没有进去对象管理时才可能走的分支
2210
+ # TODO
2211
+ # This branch is only taken during the initialization phase, when the frame has not yet entered object management.
2200
2212
  return
2201
2213
  lf = AbsFrame(rootf, {
2202
2214
  "contextId": finfo.get("contextId"),
@@ -2551,13 +2563,13 @@ class Chrome:
2551
2563
  height: '5px',
2552
2564
  backgroundColor: 'red',
2553
2565
  borderRadius: '50%',
2554
- pointerEvents: 'none', // 禁止鼠标交互
2555
- userSelect: 'none', // 禁止选中
2556
- webkitUserSelect: 'none', // Safari 兼容
2557
- mozUserSelect: 'none', // Firefox 兼容
2558
- msUserSelect: 'none', // IE/Edge 兼容
2559
- zIndex: '2147483647', // 最大 z-index 确保置顶
2560
- willChange: 'transform', // 优化渲染性能
2566
+ pointerEvents: 'none',
2567
+ userSelect: 'none',
2568
+ webkitUserSelect: 'none',
2569
+ mozUserSelect: 'none',
2570
+ msUserSelect: 'none',
2571
+ zIndex: '2147483647',
2572
+ willChange: 'transform',
2561
2573
  });
2562
2574
  document.body.appendChild(nDiv)
2563
2575
  setTimeout(function(){ nDiv.remove(); },1000)
@@ -1,3 +1,3 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vchrome
3
- Version: 0.0.0
3
+ Version: 0.0.2
@@ -0,0 +1,5 @@
1
+ vchrome/__init__.py,sha256=GaD-j4I3g4mHbDtGiCd8-5M7iXKaC7CWJiXqJH_XXyk,205606
2
+ vchrome-0.0.2.dist-info/METADATA,sha256=irZzBMagQl2VCh9fQTf-sLyWJOLcc2f0P4TWbvRpRBM,54
3
+ vchrome-0.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
+ vchrome-0.0.2.dist-info/top_level.txt,sha256=oB919Fa09PCy48Ptj8iy-1QUcvhEeY97MOR42281Fk0,8
5
+ vchrome-0.0.2.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- vchrome/__init__.py,sha256=0kIovhQyN2I2MGbc7GfqQxZoEBPxN4ALaiL5fk8utX8,205268
2
- vchrome-0.0.0.dist-info/METADATA,sha256=Ir4Nm9UhfuSB1-rBnjIcDSXOsLBOAN1OvjIpNcyXBa4,54
3
- vchrome-0.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
4
- vchrome-0.0.0.dist-info/top_level.txt,sha256=oB919Fa09PCy48Ptj8iy-1QUcvhEeY97MOR42281Fk0,8
5
- vchrome-0.0.0.dist-info/RECORD,,