mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-06-20 12:54:23 -04:00
Should be full python 3 now
This commit is contained in:
parent
5900e90e7d
commit
db9eee5f2b
2 changed files with 10 additions and 8 deletions
2
setup.py
2
setup.py
|
@ -9,7 +9,7 @@ setuptools.setup(name='umbra',
|
||||||
long_description=open('README.md').read(),
|
long_description=open('README.md').read(),
|
||||||
license='GPL',
|
license='GPL',
|
||||||
packages=['umbra'],
|
packages=['umbra'],
|
||||||
install_requires=['kombu', 'websocket-client','psutil','argparse'],
|
install_requires=['kombu', 'websocket-client-py3','psutil','argparse'],
|
||||||
scripts=['bin/umbra'],
|
scripts=['bin/umbra'],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
|
|
@ -16,10 +16,12 @@ class Umbra:
|
||||||
self.launch_tab_socket.run_forever()
|
self.launch_tab_socket.run_forever()
|
||||||
|
|
||||||
def get_websocket(self, on_open, url=None):
|
def get_websocket(self, on_open, url=None):
|
||||||
debug_info = loads(urllib.request.urlopen("http://localhost:%s/json" % self.chrome_debug_port).read())
|
def fetch_debugging_json():
|
||||||
|
return loads(urllib.request.urlopen("http://localhost:%s/json" % self.chrome_debug_port).read().decode('utf-8').replace("\\n",""))
|
||||||
|
debug_info = fetch_debugging_json()
|
||||||
if url: #Polling for the data url we used to initialize the window
|
if url: #Polling for the data url we used to initialize the window
|
||||||
while not [x for x in debug_info if x['url'] == url]:
|
while not [x for x in debug_info if x['url'] == url]:
|
||||||
debug_info = loads(urllib.request.urlopen("http://localhost:%s/json" % self.chrome_debug_port).read())
|
debug_info = fetch_debugging_json()
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
debug_info = [x for x in debug_info if x['url'] == url]
|
debug_info = [x for x in debug_info if x['url'] == url]
|
||||||
return_socket = websocket.WebSocketApp(debug_info[0]['webSocketDebuggerUrl'], on_message = self.on_message)
|
return_socket = websocket.WebSocketApp(debug_info[0]['webSocketDebuggerUrl'], on_message = self.on_message)
|
||||||
|
@ -27,9 +29,9 @@ class Umbra:
|
||||||
return return_socket
|
return return_socket
|
||||||
|
|
||||||
def on_message(self, ws, message):
|
def on_message(self, ws, message):
|
||||||
message = loads(message)
|
message = loads(message)
|
||||||
if "method" in list(message.keys()) and message["method"] == "Network.requestWillBeSent":
|
if "method" in list(message.keys()) and message["method"] == "Network.requestWillBeSent":
|
||||||
print(message)
|
pass #print(message)
|
||||||
|
|
||||||
def on_open(self, ws):
|
def on_open(self, ws):
|
||||||
self.fetch_url("http://archive.org")
|
self.fetch_url("http://archive.org")
|
||||||
|
@ -68,7 +70,7 @@ class Chrome():
|
||||||
start = time.time()
|
start = time.time()
|
||||||
open_debug_port = lambda conn: conn.laddr[1] == int(self.port)
|
open_debug_port = lambda conn: conn.laddr[1] == int(self.port)
|
||||||
chrome_ps_wrapper = psutil.Process(self.chrome_process.pid)
|
chrome_ps_wrapper = psutil.Process(self.chrome_process.pid)
|
||||||
while time.time() - start < self.browser_wait and len(list(filter(open_debug_port, chrome_ps_wrapper.get_connections()))) == 0:
|
while time.time() - start < float(self.browser_wait) and len(list(filter(open_debug_port, chrome_ps_wrapper.get_connections()))) == 0:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if len(list(filter(open_debug_port, chrome_ps_wrapper.get_connections()))) == 0:
|
if len(list(filter(open_debug_port, chrome_ps_wrapper.get_connections()))) == 0:
|
||||||
self.chrome_process.kill()
|
self.chrome_process.kill()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue