@@ -0,0 +1,2619 @@
+import json%0Aimport re%0Aimport scrapy%0Afrom locations.items import GeojsonPointItem%0A%0Aclass McDonaldsSKSpider(scrapy.Spider):%0A    name = %22mcdonalds_sk%22%0A    allowed_domains = %5B%22www.mcdonalds.sk%22%5D%0A%0A    start_urls = (%0A        'https://www.mcdonalds.sk/wp-content/themes/mcdonaldscz/rests.php',%0A    )%0A%0A    def store_hours(self, data):%0A        day = %5B%22Mo%22, %22Tu%22, %22We%22, %22Th%22, %22Fr%22, %22Sa%22, %22Su%22%5D%0A        day_groups = %5B%5D%0A        this_day_group = %7B%7D%0A        day_hours = data.split(%22,%22)%0A        weekday = 0%0A        for day_hour in day_hours:%0A            hours = ''%0A%0A            short_day = day%5Bweekday%5D%0A            hours = day_hour.strip()%0A            if not this_day_group:%0A                this_day_group = %7B%0A                    'from_day': short_day,%0A                    'to_day': short_day,%0A                    'hours': hours,%0A                %7D%0A%0A            elif hours == this_day_group%5B'hours'%5D:%0A                this_day_group%5B'to_day'%5D = short_day%0A%0A            elif hours != this_day_group%5B'hours'%5D:%0A                day_groups.append(this_day_group)%0A                this_day_group = %7B%0A                    'from_day': short_day,%0A                    'to_day': short_day,%0A                    'hours': hours,%0A                %7D%0A%0A            weekday = weekday + 1%0A%0A        day_groups.append(this_day_group)%0A%0A        if not day_groups:%0A            return None%0A        opening_hours = ''%0A        if len(day_groups) == 1 and day_groups%5B0%5D%5B'hours'%5D in ('00:00-23:59', '00:00-00:00'):%0A            opening_hours = '24/7'%0A        else:%0A            for day_group in day_groups:%0A                if day_group%5B'from_day'%5D == day_group%5B'to_day'%5D:%0A                    opening_hours += '%7Bfrom_day%7D %7Bhours%7D; '.format(**day_group)%0A                else:%0A                    opening_hours += '%7Bfrom_day%7D-%7Bto_day%7D %7Bhours%7D; '.format(**day_group)%0A            opening_hours = opening_hours %5B:-2%5D%0A%0A        return opening_hours%0A%0A    def parse(self, response):%0A        stores = json.loads(response.body_as_unicode())%0A        for store in stores:%0A            data = stores%5Bstore%5D%0A            properties = %7B%0A                'addr_full': data%5B'address'%5D,%0A                'city': data%5B'city'%5D,%0A                'ref': data%5B'id'%5D,%0A                'phone': data%5B'tel'%5D,%0A                'postcode': data%5B'zip'%5D,%0A                'name': data%5B'restaurant_name'%5D,%0A                'lat': data%5B'lat'%5D,%0A                'lon': data%5B'lng'%5D,              %0A            %7D%0A%0A            opening_hours = self.store_hours(data%5B'worktime'%5D)%0A            if opening_hours:%0A                properties%5B'opening_hours'%5D = opening_hours%0A%0A            yield GeojsonPointItem(**properties)%0A  %0A

create the Spider for Slovakia of McDonalds