Repository: alltheplaces/alltheplaces

Issue:
Sigma (IT) (AgileStoreLocator)
### Brand name

Sigma

Italian supermarket chain

### Wikidata ID

Q3977979
https://www.wikidata.org/wiki/Q3977979
https://www.wikidata.org/wiki/Special:EntityData/Q3977979.json

### Store finder url(s)

Official Url(s): https://www.supersigma.com/
- [x] I have run the below and if anything in generated, added it.
- [ ] I have manually checked for a storefinder
- [ ] This is not a manufacturer listing outlets operating under their own brands / this will not create duplicates
`pipenv run scrapy sf --brand-wikidata=Q3977979 https://www.supersigma.com/`
```
from locations.storefinders.agile_store_locator import AgileStoreLocatorSpider


class SigmaITSpider(AgileStoreLocatorSpider):
        name = "sigma_it"
        item_attributes = {
                "brand_wikidata": "Q3977979",
                "brand": "Sigma",
        }
        allowed_domains = [
                "www.supersigma.com",
        ]
```



Discussion:

Resolving patch:
diff --git a/locations/spiders/sigma_it.py b/locations/spiders/sigma_it.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/sigma_it.py
@@ -0,0 +1,28 @@
+from scrapy import Request
+
+from locations.categories import Categories
+from locations.hours import DAYS_IT, OpeningHours
+from locations.storefinders.agile_store_locator import AgileStoreLocatorSpider
+
+
+class SigmaITSpider(AgileStoreLocatorSpider):
+    name = "sigma_it"
+    item_attributes = {"brand": "Sigma", "brand_wikidata": "Q3977979", "extras": Categories.SHOP_SUPERMARKET.value}
+    allowed_domains = ["www.supersigma.com"]
+
+    def parse_item(self, item, location):
+        item["website"] = "https://www.supersigma.com/pdv/" + location["slug"] + "/"
+        yield Request(url=item["website"], meta={"item": item}, callback=self.parse_hours)
+
+    def parse_hours(self, response):
+        item = response.meta["item"]
+        item["website"] = response.url  # Capture any redirected URL
+        hours_string = " ".join(
+            filter(
+                None, map(str.strip, response.xpath('//span[contains(@class, "bkg_orari")]/span/span//text()').getall())
+            )
+        )
+        if hours_string:
+            item["opening_hours"] = OpeningHours()
+            item["opening_hours"].add_ranges_from_string(hours_string, days=DAYS_IT)
+        yield item
diff --git a/locations/storefinders/agile_store_locator.py b/locations/storefinders/agile_store_locator.py
--- a/locations/storefinders/agile_store_locator.py
+++ b/locations/storefinders/agile_store_locator.py
@@ -35,25 +35,26 @@ def start_requests(self):
     def parse(self, response, **kwargs):
         for location in response.json():
             item = DictParser.parse(location)
-            item["opening_hours"] = OpeningHours()
             item["name"] = item["name"].strip()
             item["street_address"] = item.pop("street")
-            hours_json = json.loads(location["open_hours"])
-            for day_name, hours_ranges in hours_json.items():
-                for hours_range in hours_ranges:
-                    hours_range = hours_range.upper()
-                    if not hours_range or hours_range == "0":
-                        continue
-                    if hours_range == "1":
-                        start_time = "12:00 AM"
-                        end_time = "11:59 PM"
-                    else:
-                        start_time = hours_range.split(" - ", 1)[0]
-                        end_time = hours_range.split(" - ", 1)[1]
-                    if "AM" in start_time or "PM" in start_time or "AM" in end_time or "PM" in end_time:
-                        item["opening_hours"].add_range(DAYS_EN[day_name.title()], start_time, end_time, "%I:%M %p")
-                    else:
-                        item["opening_hours"].add_range(DAYS_EN[day_name.title()], start_time, end_time)
+            if location.get("open_hours"):
+                item["opening_hours"] = OpeningHours()
+                hours_json = json.loads(location["open_hours"])
+                for day_name, hours_ranges in hours_json.items():
+                    for hours_range in hours_ranges:
+                        hours_range = hours_range.upper()
+                        if not hours_range or hours_range == "0":
+                            continue
+                        if hours_range == "1":
+                            start_time = "12:00 AM"
+                            end_time = "11:59 PM"
+                        else:
+                            start_time = hours_range.split(" - ", 1)[0]
+                            end_time = hours_range.split(" - ", 1)[1]
+                        if "AM" in start_time or "PM" in start_time or "AM" in end_time or "PM" in end_time:
+                            item["opening_hours"].add_range(DAYS_EN[day_name.title()], start_time, end_time, "%I:%M %p")
+                        else:
+                            item["opening_hours"].add_range(DAYS_EN[day_name.title()], start_time, end_time)
             yield from self.parse_item(item, location) or []
 
     def parse_item(self, item: Feature, location: dict, **kwargs):


Test patch: