aboutsummaryrefslogtreecommitdiff
path: root/backends/satyam.py
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2017-10-10 11:45:50 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2017-10-10 11:45:50 +0200
commitc9c7d389c45815e1b7abd7bea7dc5093a3630ea2 (patch)
tree1cfd621b5de112792aa2f13ea5c4997b33d0d03e /backends/satyam.py
parentaa70fb739bbcb4f7a5275fc6a8dac4b3b84579e6 (diff)
downloadmensa-c9c7d389c45815e1b7abd7bea7dc5093a3630ea2.tar.gz
mensa-c9c7d389c45815e1b7abd7bea7dc5093a3630ea2.tar.bz2
mensa-c9c7d389c45815e1b7abd7bea7dc5093a3630ea2.zip
Moved stuff to a module folder, preparing for setuptools
Diffstat (limited to 'backends/satyam.py')
-rw-r--r--backends/satyam.py38
1 files changed, 0 insertions, 38 deletions
diff --git a/backends/satyam.py b/backends/satyam.py
deleted file mode 100644
index ec488f3..0000000
--- a/backends/satyam.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import urllib.request, urllib.error, urllib.parse
-from lxml import etree
-from lxml.cssselect import CSSSelector
-import html5lib
-from base import *
-import re
-import sys
-from yapsy.IPlugin import IPlugin
-
-class Satyam(IPlugin):
- def register_restaurants(self) :
- r = Restaurant("Satyam", "Satyam", self, "dummy")
- register_restaurant(r)
- def get_food_items(self, **kwargs) :
- s = sys.stderr
- 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 €", "")
- sys.stderr = s
- return [Food("Mittagstisch Express", "5,95 €", "Mittagstisch", 2, name[3:-1])]
-
-
-# if __name__ == "__main__":
-# food = get_food_items()
-# print(formt(food))