Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Commit

Permalink
Convert price to €/l.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Feb 17, 2016
1 parent 5392610 commit 5e56c3f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import lxml.html


def inner_html(self):
return self.text_content().lstrip().rstrip()
def inner_html(html):
return html.text_content().strip()

def nicename(self):
return self.lower().replace(u'ä', 'ae').replace(u'ö', 'oe').replace(u'ü', 'ue')

def nicename(name):
return name.lower().replace(u'ä', 'ae').replace(u'ö', 'oe').replace(u'ü', 'ue')


def price_per_liter(price):
return float(".%s" % price.replace(u'€', '').rstrip().replace(',', ''))


html = scraperwiki.scrape("http://www.fastenergy.at/heizoelpreis-tendenz.htm")
Expand All @@ -27,9 +32,8 @@ def nicename(self):
data={
"id": nicename(name),
"name": name,
"price_today": price_today,
"price_yesterday": price_yesterday,
"price_difference": price_difference
},
table_name='data'
"price_today": price_per_liter(price_today),
"price_yesterday": price_per_liter(price_yesterday),
"price_difference": price_per_liter(price_difference)
}
)

0 comments on commit 5e56c3f

Please sign in to comment.