Skip to content

Commit

Permalink
Fork of code from ScraperWiki at https://classic.scraperwiki.com/scra…
Browse files Browse the repository at this point in the history
  • Loading branch information
misanovic committed Jul 16, 2014
0 parents commit 2bd5b6c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
# Ignore output of scraper
data.sqlite
22 changes: 22 additions & 0 deletions scraper.py
@@ -0,0 +1,22 @@
import scraperwiki
import lxml.html
from datetime import datetime

URL='http://www.caltex.com.au/LatestNews/FuelPricing/Pages/TerminalGatePricing.aspx'
FUELS=['Diesel']
TERMINALS=['Devonport']

def main():
index_html = scraperwiki.scrape(URL)
index = lxml.html.fromstring(index_html)
# '//*[@id="main"]/div[2]/div[2]/table/tbody/tr[10]/td[7]'
dates = index.cssselect('div.EffectiveDates')
print 'Effective Dates: %s\n' % dates[0].text_content()
for terminal in TERMINALS:
for fuel in FUELS:
for date in ['Current','Previous']:
price = index.cssselect('td[headers="%s %s-%s %s"]' % (fuel,fuel,date,terminal))[0].text_content()
print '%s %s %s: %s' % (fuel,terminal, date, price)

main()

0 comments on commit 2bd5b6c

Please sign in to comment.