Skip to content

Commit

Permalink
Merge pull request #10 from helb/zomato
Browse files Browse the repository at this point in the history
Fix Zomato parser, thanks @VojtechMyslivec
  • Loading branch information
helb committed Jul 3, 2019
2 parents 48608cc + 3973ff8 commit 5b5f041
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions ansible-role/tasks/main.yml
Expand Up @@ -12,9 +12,8 @@

- name: Install apt requirements
apt:
name: '{{ item }}'
name: '{{ jidlobot_requirements }}'
state: present
with_items: '{{ jidlobot_requirements }}'

- name: Clone jidlobot repo
git:
Expand Down
3 changes: 2 additions & 1 deletion ansible-role/templates/jidlobot.yml.j2
@@ -1,7 +1,8 @@
## jidlobot.conf

HTTP_TIMEOUT: 5
ZOMATO_UA: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3452.0 Safari/537.36'
ZOMATO_UA: 'Mozilla/5.0 (X11; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0'
ZOMATO_LANG: 'cs,en'

URLS:
{% for url in jidlobot_urls %}
Expand Down
7 changes: 6 additions & 1 deletion jidlobot.yml.example
@@ -1,3 +1,5 @@
---

HTTP_TIMEOUT: 5
URLS:
- https://www.menicka.cz/1631-u-malicke-brany.html
Expand Down Expand Up @@ -27,4 +29,7 @@ BACKENDS:
- hipchat
- console

ZOMATO_UA: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3452.0 Safari/537.36
ZOMATO_UA: 'Mozilla/5.0 (X11; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0'
ZOMATO_LANG: 'cs,en'

...
3 changes: 2 additions & 1 deletion zomato.py
Expand Up @@ -10,9 +10,10 @@ def fetch(url, config):
prices = []

try:
url = re.sub(r"\?.*/?(daily-menu)?$", "/daily-menu", url)
url = re.sub(r"\?.*/?(daily-menu|denní-menu)?$", "/denní-menu", url)
result = requests.get(url, timeout=config["HTTP_TIMEOUT"], headers={
"User-Agent": config["ZOMATO_UA"],
"Accept-Language": config["ZOMATO_LANG"],
"Referer": url
})
html = BeautifulSoup(result.content, "html5lib")
Expand Down

0 comments on commit 5b5f041

Please sign in to comment.