Skip to content

Instantly share code, notes, and snippets.

@neerajvashistha
Forked from caiosba/dollar-reais-indicator.py
Last active November 4, 2019 05:14
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 neerajvashistha/cf11904bdd4554a284b8c5b60146ae14 to your computer and use it in GitHub Desktop.
Save neerajvashistha/cf11904bdd4554a284b8c5b60146ae14 to your computer and use it in GitHub Desktop.
Ubuntu Unity Indicator to show current gbp value in indian rupee (auto-updates every minute)
#!/usr/bin/env python
# Unity indicator for dolar/real currency
# Author: Caio Almeida <caiosba@gmail.com>
# 05 Jul 2016
import gobject
import gtk
import appindicator
import os, sys
import time
from time import gmtime, strftime
#from BeautifulSoup import BeautifulSoup as bs
from bs4 import BeautifulSoup as bs
import urlparse
import urllib2
from urllib import urlretrieve
if __name__ == "__main__":
def update(args=None):
url = 'https://br.investing.com/currencies/gbp-inr'
soup = bs(urllib2.urlopen(urllib2.Request(url, headers = { 'User-Agent': 'Mozilla/5.0' })), "lxml")
#value = '1GBP=' + soup.find('span', { 'id' : 'last_last' }).string.replace(',','.')+'INR'
value = '1'+u"\u00A3"+'='u"\u20B9" + soup.find('span', { 'id' : 'last_last' }).string.replace(',','.')
ind.set_label(value)
item.set_label(value)
return True
icon_image = "/usr/share/unity/icons/refine_gradient_panel_single_column.png"
ind = appindicator.Indicator('dollar-real-client', icon_image, appindicator.CATEGORY_APPLICATION_STATUS)
ind.set_status(appindicator.STATUS_ACTIVE)
ind.set_label('Updating...')
menu = gtk.Menu()
item = gtk.MenuItem('Updating...')
item.show()
menu.append(item)
ind.set_menu(menu)
update()
gtk.timeout_add(60000, update)
gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment