Last active
February 13, 2016 00:25
-
-
Save kurozumi/78861444ab46ad5e70ba to your computer and use it in GitHub Desktop.
【Python】Macのsayコマンドを使ってヤフーニュースを読み上げる
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
# coding:utf-8 | |
import urllib2 | |
from bs4 import BeautifulSoup | |
import subprocess | |
def say(): | |
html = urllib2.urlopen("http://headlines.yahoo.co.jp/hl?a=20160212-00000044-asahi-brf") | |
soup = BeautifulSoup(html, "lxml") | |
for t in soup.select(".ynDetailText"): | |
text = t.get_text().strip() | |
subprocess.call('say "%s"' % text, shell=True) | |
if __name__ == "__main__": | |
say() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment