Last active
December 21, 2015 18:58
-
-
Save varmais/6350563 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#coding: utf-8 | |
from BeautifulSoup import BeautifulSoup | |
from urllib2 import urlopen | |
viikonsafkat = {} | |
def haeLista2(): | |
url = 'http://www.amica.fi/paaraide#Ruokalista' | |
html = urlopen(url).read() | |
soup = BeautifulSoup(html) | |
safkat = soup.find('div', 'ContentArea OrangeHeader') | |
for n in range(0,10): | |
if n%2 != 0: | |
safka = safkat.findAll('p')[n] | |
paiva = safkat.findAll('p')[n-1] | |
safka = ''.join(safka.findAll(text=True)) | |
paiva = ''.join(paiva.findAll(text=True)).lower()[:2] | |
viikonsafkat[paiva] = safka | |
def toSQL(paiva, ruoka): | |
print paiva | |
print ruoka | |
def tulosta(): | |
for paiva,ruoka in viikonsafkat.iteritems(): | |
toSQL(paiva, ruoka) | |
haeLista2() | |
tulosta() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment