Skip to content

Instantly share code, notes, and snippets.

@ShinJJang
Created September 5, 2017 10:04
Show Gist options
  • Save ShinJJang/6c21762e4c362ca7d79541c3934dd7c6 to your computer and use it in GitHub Desktop.
Save ShinJJang/6c21762e4c362ca7d79541c3934dd7c6 to your computer and use it in GitHub Desktop.
Bitbar plugin - KRW to JPY Currency tracker from http://finance.daum.net
#!/usr/bin/python
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
from urllib import urlencode
from urllib2 import Request, urlopen
from datetime import datetime
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# Write here the currency you want to see
currTo = "JPY"
baseUrl="http://finance.daum.net/exchange/exchangeDetail.daum?code="
url = baseUrl + currTo
# web parsing
req = Request(url)
response = urlopen(req)
result = response.read().decode('euc-kr')
soup = BeautifulSoup(result, "html.parser")
# get currency rate
currency = soup.find('dd', id='hyenCost')
rate = soup.find('dd', id='hyenUpdn')
print "KRW : %s (%s)" % (currency.text, rate.text)
print "---"
print "Last update : %s" % datetime.today()
print "made by shinjjang"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment