1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
|
|
try: |
4
|
|
|
import traceback |
5
|
|
|
import logging |
6
|
|
|
import sys |
7
|
|
|
import os |
8
|
|
|
import re |
9
|
|
|
import json |
10
|
|
|
from osm_poi_matchmaker.libs.soup import save_downloaded_soup |
11
|
|
|
from osm_poi_matchmaker.libs.address import extract_street_housenumber_better_2, clean_city, \ |
12
|
|
|
extract_javascript_variable, clean_opening_hours |
13
|
|
|
from osm_poi_matchmaker.libs.geo import check_hu_boundary |
14
|
|
|
from osm_poi_matchmaker.libs.osm_tag_sets import POS_HU_GEN, PAY_CASH |
15
|
|
|
from osm_poi_matchmaker.utils.enums import WeekDaysLong |
16
|
|
|
from osm_poi_matchmaker.utils.data_provider import DataProvider |
17
|
|
|
from osm_poi_matchmaker.utils.enums import FileType |
18
|
|
|
except ImportError as err: |
19
|
|
|
logging.error('Error %s import module: %s', __name__, err) |
20
|
|
|
logging.error(traceback.print_exc()) |
21
|
|
|
sys.exit(128) |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
class hu_rossmann(DataProvider): |
25
|
|
|
|
26
|
|
|
def constains(self): |
27
|
|
|
self.link = 'https://www.rossmann.hu/uzletkereso' |
28
|
|
|
self.POI_COMMON_TAGS = "" |
29
|
|
|
self.filetype = FileType.html |
30
|
|
|
self.filename = '{}.{}'.format(self.__class__.__name__, self.filetype.name) |
31
|
|
|
|
32
|
|
|
def types(self): |
33
|
|
|
self.__types = [{'poi_code': 'hurossmche', 'poi_name': 'Rossmann', 'poi_type': 'chemist', |
34
|
|
|
'poi_tags': "{'shop': 'chemist', 'operator': 'Rossmann Magyarország Kft.', |
|
|
|
|
35
|
|
|
'operator:addr': '2225 Üllő, Zsaróka út 8.', 'ref:vatin:hu': '11149769-2-44', |
36
|
|
|
'ref:vatin': 'HU11149769', 'brand':'Rossmann', 'brand:wikidata': 'Q316004', |
37
|
|
|
'brand:wikipedia': 'de:Dirk Rossmann GmbH', 'contact:email': '[email protected]', |
38
|
|
|
'phone': '+36 29 889-800;+36 70 4692 800', 'contact:facebook':'https://www.facebook.com/Rossmann.hu', |
39
|
|
|
'contact:youtube': 'https://www.youtube.com/channel/UCmUCPmvMLL3IaXRBtx7-J7Q', |
40
|
|
|
'contact:instagram':'https://www.instagram.com/rossmann_hu', " + POS_HU_GEN + PAY_CASH + "'air_conditioning': 'yes'}", |
41
|
|
|
'poi_url_base': 'https://www.rossmann.hu', 'poi_search_name': 'rossmann', 'osm_search_distance_perfect': 2000, 'osm_search_distance_safe': 200, 'osm_search_distance_unsafe': 3}] |
42
|
|
|
return self.__types |
43
|
|
|
|
44
|
|
|
def process(self): |
45
|
|
|
try: |
46
|
|
|
soup = save_downloaded_soup('{}'.format(self.link), os.path.join(self.download_cache, self.filename), |
47
|
|
|
self.filetype, None, self.verify_link) |
48
|
|
|
if soup is not None: |
49
|
|
|
# parse the html using beautiful soap and store in variable `soup` |
50
|
|
|
text = json.loads(extract_javascript_variable(soup, 'places')) |
51
|
|
|
for poi_data in text: |
52
|
|
|
poi_data = poi_data['addresses'][0] |
53
|
|
|
# Assign: code, postcode, city, name, branch, website, original, street, housenumber, conscriptionnumber, ref, geom |
54
|
|
|
self.data.name = 'Rossmann' |
55
|
|
|
self.data.code = 'hurossmche' |
56
|
|
|
self.data.city = clean_city(poi_data['city']) |
57
|
|
|
self.data.postcode = poi_data.get('zip').strip() |
58
|
|
|
for i in range(0, 7): |
59
|
|
|
if poi_data['business_hours'][WeekDaysLong(i).name.lower()] is not None: |
60
|
|
|
opening, closing = clean_opening_hours(poi_data['business_hours'][WeekDaysLong(i).name.lower()]) |
61
|
|
|
self.data.day_open_close(i, opening, closing) |
62
|
|
|
else: |
63
|
|
|
self.data.day_open_close(i, None, None) |
64
|
|
|
self.data.lat, self.data.lon = check_hu_boundary(poi_data['position'][0], poi_data['position'][1]) |
65
|
|
|
self.data.street, self.data.housenumber, self.data.conscriptionnumber = extract_street_housenumber_better_2( |
66
|
|
|
poi_data['address']) |
67
|
|
|
self.data.original = poi_data['address'] |
68
|
|
|
self.data.public_holiday_open = False |
69
|
|
|
self.data.add() |
70
|
|
|
except Exception as e: |
71
|
|
|
logging.error(traceback.print_exc()) |
72
|
|
|
logging.error(e) |
73
|
|
|
|