Created
April 10, 2014 19:38
-
-
Save awentzonline/10415560 to your computer and use it in GitHub Desktop.
ROBOT READS YOU A WEB FRAGMENT
This file contains hidden or 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
| import subprocess | |
| import sys | |
| import lxml.html | |
| import requests | |
| if __name__ == '__main__': | |
| url, selector = sys.argv[-2:] | |
| response = requests.get(url) | |
| doc = lxml.html.fromstring(response.content) | |
| text = [] | |
| for elm in doc.cssselect(selector): | |
| text.append(elm.text_content().encode('utf-8')) | |
| try: | |
| subprocess.call(['say', '. '.join(text)]) | |
| except KeyboardInterrupt: | |
| pass |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save it as wwwblab.py and then:
python wwwblab.py "http://www.cnn.com/2014/04/10/wor/asia/malaysia-airlines-plane/index.html?hpt=hp_t1" ".cnn_strycntntlft p"