vchrome 0.0.16__py3-none-any.whl → 0.0.17__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 +28 -15
- {vchrome-0.0.16.dist-info → vchrome-0.0.17.dist-info}/METADATA +1 -1
- vchrome-0.0.17.dist-info/RECORD +6 -0
- vchrome-0.0.16.dist-info/RECORD +0 -6
- {vchrome-0.0.16.dist-info → vchrome-0.0.17.dist-info}/WHEEL +0 -0
- {vchrome-0.0.16.dist-info → vchrome-0.0.17.dist-info}/top_level.txt +0 -0
vchrome/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
__version__ = '0.0.
|
|
1
|
+
__version__ = '0.0.17'
|
|
2
2
|
__author__ = 'v'
|
|
3
3
|
# ----------------------------------------------------------------------------------------------------
|
|
4
4
|
_allowed = {'Chrome'}
|
|
@@ -1930,6 +1930,7 @@ def cdp_client(hostname, port, debug=False):
|
|
|
1930
1930
|
c._js2py = self.f._js2py
|
|
1931
1931
|
c.tabs = self.f.root.tabs
|
|
1932
1932
|
c.quit = self.f.root.quit
|
|
1933
|
+
c.open_devtools = self.f.open_devtools
|
|
1933
1934
|
c.press = self.f.press
|
|
1934
1935
|
c.release = self.f.release
|
|
1935
1936
|
c.id = self.f.id
|
|
@@ -2129,6 +2130,17 @@ def cdp_client(hostname, port, debug=False):
|
|
|
2129
2130
|
self.keyboard = Keyboard(self)
|
|
2130
2131
|
def press(self, key): self.cdp('Input.dispatchKeyEvent', self.keyboard._make_down(key))
|
|
2131
2132
|
def release(self, key): self.cdp('Input.dispatchKeyEvent', self.keyboard._make_up(key))
|
|
2133
|
+
def open_devtools(self, show=False):
|
|
2134
|
+
url = 'devtools://devtools/bundled/inspector.html?ws=' + self.wsinfo['webSocketDebuggerUrl'].split('//', 1)[-1]
|
|
2135
|
+
wslist = myget(wurl)
|
|
2136
|
+
has_open = False
|
|
2137
|
+
for wsinfo in wslist:
|
|
2138
|
+
if wsinfo.get('url') == url:
|
|
2139
|
+
has_open = True
|
|
2140
|
+
break
|
|
2141
|
+
if not has_open:
|
|
2142
|
+
t = self.root.rootchrome.new_tab(show)
|
|
2143
|
+
t.get(url)
|
|
2132
2144
|
def close(self):
|
|
2133
2145
|
self.cdp('Target.closeTarget', {"targetId": self.frameId})
|
|
2134
2146
|
while self.closer.toggle:
|
|
@@ -2218,6 +2230,7 @@ def cdp_client(hostname, port, debug=False):
|
|
|
2218
2230
|
self._wok_script.append(script)
|
|
2219
2231
|
else:
|
|
2220
2232
|
raise Exception('type must in (page/worker) default is page.')
|
|
2233
|
+
self.init_once = False
|
|
2221
2234
|
def _page_init_js(self, sessionId=None):
|
|
2222
2235
|
if self._doc_script:
|
|
2223
2236
|
for s in self._doc_script:
|
|
@@ -2299,9 +2312,9 @@ def cdp_client(hostname, port, debug=False):
|
|
|
2299
2312
|
self.e.ws.close()
|
|
2300
2313
|
self.e = e
|
|
2301
2314
|
class Root:
|
|
2302
|
-
def __init__(self,
|
|
2315
|
+
def __init__(self, version, iframes):
|
|
2303
2316
|
self.pool = Pool(10)
|
|
2304
|
-
self.
|
|
2317
|
+
self.version = version
|
|
2305
2318
|
self.iframes = iframes
|
|
2306
2319
|
self.active = None
|
|
2307
2320
|
self.detached_cache_sessionId = {}
|
|
@@ -2311,7 +2324,7 @@ def cdp_client(hostname, port, debug=False):
|
|
|
2311
2324
|
self.tabs = []
|
|
2312
2325
|
self.is_init = True
|
|
2313
2326
|
self.init_sign = 0
|
|
2314
|
-
self.ws = create_connection_saf(
|
|
2327
|
+
self.ws = create_connection_saf(version['webSocketDebuggerUrl'], enable_multithread=True, suppress_origin=True)
|
|
2315
2328
|
self.logger = Logger('[[ ---------- ROOT ---------- ]]', debug)
|
|
2316
2329
|
self.cdper = CoreCDP(self, self.ws, self, self.logger)
|
|
2317
2330
|
self.cdper.attach(self)
|
|
@@ -2471,10 +2484,10 @@ def cdp_client(hostname, port, debug=False):
|
|
|
2471
2484
|
wslist = myget(wurl)
|
|
2472
2485
|
for idx in range(len(wslist)):
|
|
2473
2486
|
wslist[idx]['webSocketDebuggerUrl'] = adj_wsurl(wslist[idx]['webSocketDebuggerUrl'])
|
|
2474
|
-
|
|
2475
|
-
|
|
2487
|
+
version = myget(wvurl)
|
|
2488
|
+
version['webSocketDebuggerUrl'] = adj_wsurl(version['webSocketDebuggerUrl'])
|
|
2476
2489
|
iframes = [i for i in wslist if i['type'] == 'iframe']
|
|
2477
|
-
root = Root(
|
|
2490
|
+
root = Root(version, iframes)
|
|
2478
2491
|
for wsinfo in wslist: RootFrame(wsinfo, root)
|
|
2479
2492
|
start = perf_counter()
|
|
2480
2493
|
while root.init_sign:
|
|
@@ -2643,7 +2656,7 @@ class Chrome:
|
|
|
2643
2656
|
hostname = '127.0.0.1',
|
|
2644
2657
|
user_path = None,
|
|
2645
2658
|
use_system_user_path = False,
|
|
2646
|
-
|
|
2659
|
+
version_check = True,
|
|
2647
2660
|
headless = False,
|
|
2648
2661
|
incognito = False,
|
|
2649
2662
|
user_agent = None,
|
|
@@ -2654,7 +2667,7 @@ class Chrome:
|
|
|
2654
2667
|
):
|
|
2655
2668
|
self.debug = Debug(debug)
|
|
2656
2669
|
self.path = find_chrome(path)
|
|
2657
|
-
self.
|
|
2670
|
+
self.version_check = version_check
|
|
2658
2671
|
self.headless = headless
|
|
2659
2672
|
self.user_agent = user_agent
|
|
2660
2673
|
self.incognito = incognito
|
|
@@ -2739,9 +2752,9 @@ class Chrome:
|
|
|
2739
2752
|
platform = property(lambda s:s.get_platform(), lambda s,v:s.set_platform(v))
|
|
2740
2753
|
def _check_lower_version(self):
|
|
2741
2754
|
try:
|
|
2742
|
-
|
|
2743
|
-
if
|
|
2744
|
-
ver = int(
|
|
2755
|
+
version = self.dr.root.version
|
|
2756
|
+
if version and version.get('Browser'):
|
|
2757
|
+
ver = int(version.get('Browser').split('/')[-1].split('.')[0])
|
|
2745
2758
|
# Restricting Chrome versions to prevent abnormal states
|
|
2746
2759
|
if ver < 100:
|
|
2747
2760
|
return True
|
|
@@ -2756,8 +2769,8 @@ class Chrome:
|
|
|
2756
2769
|
if not self.dr:
|
|
2757
2770
|
raise Exception('maybe single devtools not close.')
|
|
2758
2771
|
self.dr.browser.attach(self)
|
|
2759
|
-
if self.
|
|
2760
|
-
raise Exception('chrome
|
|
2772
|
+
if self.version_check and self._check_lower_version():
|
|
2773
|
+
raise Exception('chrome version is less then 100. not reliable. you can set (version_check=False) for ignore this alert.')
|
|
2761
2774
|
if self.debug.mouse:
|
|
2762
2775
|
jscode = r'''
|
|
2763
2776
|
function f(e){
|
|
@@ -4305,4 +4318,4 @@ class WebSocketApp:
|
|
|
4305
4318
|
except Exception as e:
|
|
4306
4319
|
_logging.error(f'error from callback {callback}: {e}')
|
|
4307
4320
|
if self.on_error:
|
|
4308
|
-
self.on_error(self, e)
|
|
4321
|
+
self.on_error(self, e)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
v/__init__.py,sha256=6DurnAoxIMJqDiwNpfsnSnHSysKaZO33FFF4aRJR1Qg,108
|
|
2
|
+
vchrome/__init__.py,sha256=TPHiPMCANh8HGZ3vw0nGxHeDUaV2rzD39EWAAsaPVcU,222137
|
|
3
|
+
vchrome-0.0.17.dist-info/METADATA,sha256=8UnspeHU0D9LeD66Rs26az3npJyHZq2wFj024_CSTso,57
|
|
4
|
+
vchrome-0.0.17.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
5
|
+
vchrome-0.0.17.dist-info/top_level.txt,sha256=IYbkbnFb2FGoroYj_ZXIitmnJDgYBA29_HmK9BdEUkY,10
|
|
6
|
+
vchrome-0.0.17.dist-info/RECORD,,
|
vchrome-0.0.16.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
v/__init__.py,sha256=6DurnAoxIMJqDiwNpfsnSnHSysKaZO33FFF4aRJR1Qg,108
|
|
2
|
-
vchrome/__init__.py,sha256=XXig0wh1XDewBpfcj0vtd_FmAKbO1Y5Gss1-JfJmyMY,221557
|
|
3
|
-
vchrome-0.0.16.dist-info/METADATA,sha256=6KXJkfLHI485HjRNCVJp5dOsSTEnI1Sn2bIfaBxWTgQ,57
|
|
4
|
-
vchrome-0.0.16.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
5
|
-
vchrome-0.0.16.dist-info/top_level.txt,sha256=IYbkbnFb2FGoroYj_ZXIitmnJDgYBA29_HmK9BdEUkY,10
|
|
6
|
-
vchrome-0.0.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|