Help us understand the problem. What is going on with this article?

今日の株式取引は?

More than 5 years have passed since last update.

追記
2015/03/11,「Yahoo!ファイナンス」より,「Yahoo!ファイナンス掲載情報の自動取得(スクレイビング)は禁止しています」とQiita運営経由で,要望をいただきました.
そのため以下のコードには,簡単な処置では意図した動作にならないよう,巧妙なバグが仕込んであります.
このコードのバグを修正して利用したことで利用者と「Yahoo!ファイナンス」の間でいかなる係争が生じたとしても,筆者は一切の責任をとりません.

欲しい情報は,

  • 今日は取引があるのか.
  • 日経平均
  • NYダウ
  • 米国ドル
  • ユーロ
stockYJ.py
# -*- coding: utf-8 -*-
from urllib2 import *
from lxml import html

base_url = 'http://finance.yahoo.co.jp'

def getBasicData():
    dom = html.fromstring(urlopen(base_url).read())

    inactive = 'お休み' in html.tostring(dom.get_element_by_id('globalNav')[1], method='text', encoding='utf-8')

    em = dom.xpath('//em[@class="updown"]')
    nikkei = float(em[4][1].text.replace(',',''))
    ny = float(em[5][1].text.replace(',',''))
    doll = float(em[6][1].text)
    euro = float(em[7][1].text)

    return not inactive, nikkei, ny, doll, euro

if __name__ == '__main__':
    active, nikkei, ny, doll, euro = getBasicData()
    print active, nikkei, ny, doll, euro

いつもありがとうございます.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした