Repository: alltheplaces/alltheplaces

Issue:
Snap Fitness
https://www.snapfitness.com/gyms


Discussion:
This issue hasn't been worked on in a while. I'm removing the assignment so others can work on it. If you're still working on it, please reassign yourself and reference a pull request or branch where you're doing your work.
Australia:
JSON response with all locations: `https://www.snapfitness.com/au/api/location-finder-edge`

Belgium:
JSON response with all locations: `https://www.snapfitness.com/be/api/location-finder-edge`

Canada:
JSON response with all locations: `https://www.snapfitness.com/ca/api/location-finder-edge`

Spain:
JSON response with all locations: `https://www.snapfitness.com/es/api/location-finder-edge`

Hong Kong:
JSON response with all locations: `https://www.snapfitness.com/hk/api/location-finder-edge` or `https://www.snapfitness.com/hk_en/api/location-finder-edge`

Indonesia:
JSON response with all locations: `https://www.snapfitness.com/id/api/location-finder-edge` or `https://www.snapfitness.com/id_en/api/location-finder-edge`

Ireland:
JSON response with all locations: `https://www.snapfitness.com/ie/api/location-finder-edge`

Japan:
CrawlSpider needed for start URL: `https://www.snapfitness.jp/locations/`

Mexico:
JSON response with all locations: `https://www.snapfitness.com/mx/api/location-finder-edge`

Netherlands:
JSON response with all locations: `https://www.snapfitness.com/nl/api/location-finder-edge`

New Zealand:
JSON response with all locations: `https://www.snapfitness.com/nz/api/location-finder-edge`

Philippines:
JSON response with all locations: `https://www.snapfitness.com/ph/api/location-finder-edge`

Saudi Arabia:
JSON response with all locations: `https://www.snapfitness.com/sa_en/api/location-finder-edge`

Singapore:
JSON response with all locations: `https://www.snapfitness.com/sg/api/location-finder-edge`

Taiwan:
JSON response with all locations: `https://www.snapfitness.com/tw/api/location-finder-edge`

Resolving patch:
diff --git a/locations/spiders/snap_fitness.py b/locations/spiders/snap_fitness.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/snap_fitness.py
@@ -0,0 +1,64 @@
+from scrapy import Spider
+from scrapy.http import JsonRequest
+
+from locations.dict_parser import DictParser
+from locations.hours import DAYS, OpeningHours
+from locations.structured_data_spider import clean_facebook, clean_instagram
+
+
+class SnapFitnessSpider(Spider):
+    name = "snap_fitness"
+    item_attributes = {"brand": "Snap Fitness", "brand_wikidata": "Q7547254"}
+    allowed_domains = ["www.snapfitness.com"]
+    country_codes = [
+        "ae",
+        "au",
+        "be",
+        "ca",
+        "es",
+        "hk",
+        "id",
+        "ie",
+        "mx",
+        "nl",
+        "nz",
+        "ph",
+        "sa_en",
+        "sg",
+        "tr",
+        "tw",
+        "uk",
+        "us",
+    ]
+
+    def start_requests(self):
+        for country_code in self.country_codes:
+            yield JsonRequest(url=f"https://www.snapfitness.com/{country_code}/api/location-finder-edge")
+
+    def parse(self, response):
+        for location in response.json()["items"]:
+            item = DictParser.parse(location["customProperties"]["contactDetails"])
+            item["ref"] = location["id"]
+            item["name"] = location["name"]
+            item["lat"] = location["customProperties"]["latitude"]
+            item["lon"] = location["customProperties"]["longitude"]
+            item["street_address"] = ", ".join(
+                filter(
+                    None,
+                    [
+                        location["customProperties"]["contactDetails"].get("address"),
+                        location["customProperties"]["contactDetails"].get("address2"),
+                    ],
+                )
+            )
+            item["website"] = response.url.replace("/api/location-finder-edge", location["urlPath"])
+            if not item.get("extras"):
+                item["extras"] = {}
+            item["extras"]["contact:instagram"] = clean_instagram(
+                location["customProperties"]["contactDetails"].get("instagramUrl", "")
+            )
+            item["facebook"] = clean_facebook(location["customProperties"]["contactDetails"].get("facebookUrl", ""))
+            if location["customProperties"]["contactDetails"].get("open24Hours"):
+                item["opening_hours"] = OpeningHours()
+                item["opening_hours"].add_days_range(DAYS, "00:00", "23:59")
+            yield item


Test patch: