Skip to content

Instantly share code, notes, and snippets.

@baongoc124
Last active April 8, 2017 16:27
Show Gist options
  • Save baongoc124/ab7fab56f9f95363c75ff79b19257b60 to your computer and use it in GitHub Desktop.
Save baongoc124/ab7fab56f9f95363c75ff79b19257b60 to your computer and use it in GitHub Desktop.
web complete script for google chrome/chromium
#!/usr/bin/python2
from __future__ import print_function
# https://github.com/benslk/chrome_remote_shell
# should be installed from git. Using PIP to install will only get older, not working version
import chrome_remote_shell, json
import re
shell = chrome_remote_shell.Shell(host='localhost', port=9222)
shell.connect(0)
navcom = json.dumps({"id":0, "method":"Runtime.evaluate", "params":{"expression": "document.body.innerText"}})
shell.soc.send(navcom)
response = json.loads(shell.soc.recv())
data = response['result']['result']['value']
data = set(re.split('\W', data))
data = filter(lambda s: len(s) > 4, data)
print(u'\n'.join(data).encode('utf-8').strip())
@oschrenk
Copy link

oschrenk commented Apr 8, 2017

Ugh. It worked for a second and now it's reporting empty content again and chrome-remote-interface is reporting another extension. I opened an issue at cyrus-and/chrome-remote-interface#91 maybe they have an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment