diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2017-10-04 00:42:18 +0200 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2017-10-04 00:42:18 +0200 |
commit | 2195b639091842492ea11ab8b91a631c59a7d32f (patch) | |
tree | 89188abfb8f129056c3ec45e8e76a501df694e43 /satyam.py | |
parent | 588a1df9f0ae350c3593156ebb102835a4124115 (diff) | |
download | mensa-2195b639091842492ea11ab8b91a631c59a7d32f.tar.gz mensa-2195b639091842492ea11ab8b91a631c59a7d32f.tar.bz2 mensa-2195b639091842492ea11ab8b91a631c59a7d32f.zip |
Modularized program
Diffstat (limited to 'satyam.py')
-rw-r--r-- | satyam.py | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/satyam.py b/satyam.py deleted file mode 100644 index 19e8387..0000000 --- a/satyam.py +++ /dev/null @@ -1,34 +0,0 @@ -import urllib.request, urllib.error, urllib.parse -from lxml import etree -from lxml.cssselect import CSSSelector -import html5lib -from common import Food -from common import formt -import re -import sys - - -def get_food_items() : - sys.stderr = open("/dev/null", "w") - user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)' - headers = {'User-Agent': user_agent} - - req = urllib.request.Request('http://www.mysatyam.de/angebote/express-mittagstisch.html', headers=headers) - response = urllib.request.urlopen(req) - the_page = response.read() - document = html5lib.parse(the_page, treebuilder="lxml") - groupsel = CSSSelector('.news-latest-item-content') - k = etree.tostring(groupsel(document)[0]) - name = re.sub(r'<.+?>', ' ', str(k)) - name = etree.fromstring("<p>%s</p>"%name).text.strip() - name = name.replace("\\n", "") - name = " ".join(name.split()) - - name = name.replace("5,95 €", "") -# print(name[3:-1]) - return [Food("Mittagstisch Express", "5,95 €", "Mittagstisch", 2, name[3:-1])] - - -if __name__ == "__main__": - food = get_food_items() - print(formt(food)) |