Last active
April 8, 2017 16:27
-
-
Save baongoc124/ab7fab56f9f95363c75ff79b19257b60 to your computer and use it in GitHub Desktop.
web complete script for google chrome/chromium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.