Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active February 13, 2016 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurozumi/78861444ab46ad5e70ba to your computer and use it in GitHub Desktop.
Save kurozumi/78861444ab46ad5e70ba to your computer and use it in GitHub Desktop.
【Python】Macのsayコマンドを使ってヤフーニュースを読み上げる
# 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