Skip to content

Instantly share code, notes, and snippets.

@peterdalle
Last active August 29, 2015 14:24
Show Gist options
  • Save peterdalle/0889506cb7e7000b2fff to your computer and use it in GitHub Desktop.
Save peterdalle/0889506cb7e7000b2fff to your computer and use it in GitHub Desktop.
Hämta det billigaste bensinpriset i Göteborg
# Visa det billigaste bensinpriset i Göteborg, via bensinpriser.se.
import requests # pip install requests
from bs4 import BeautifulSoup # pip install BeautifulSoup4
r = requests.get('http://www.bensinpriser.se/v%C3%A4stra-g%C3%B6talands-l%C3%A4n/g%C3%B6teborg/g%C3%B6teborg')
soup = BeautifulSoup(r.text, "lxml") # pip install lxml
rowIndex = 0
for row in soup.select(".resulttable tr"):
rowIndex = rowIndex + 1
tableCells = row.findAll('td')
if rowIndex == 2:
if len(tableCells) > 0:
bolag = tableCells[1].string
pris95oktan = tableCells[2].string
print bolag + ": " + pris95oktan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment