Repository: alltheplaces/alltheplaces

Issue:
BashasSpider - can this be rewritted as a WPStoreLocator Spider?
Not sure if there is anything too unique about it.
```
class BashasSpider(scrapy.spiders.SitemapSpider):
    name = "bashas"
    item_attributes = {
        "brand": "Bashas'",
        "brand_wikidata": "Q4866786",
    }

    download_delay = 0.2
    sitemap_urls = ["https://www.bashas.com/wpsl_stores-sitemap.xml"]
    sitemap_rules = [("/stores/", "parse_store")]

    def parse_store(self, response):
        script = response.xpath("//script[@id='wpsl-js-js-extra']/text()").extract_first()
        open_brace = script.find('"locations":[{') + 13
        close_brace = script.rfind("}]}") + 1
        store_json = json.loads(script[open_brace:close_brace])
        hours = response.xpath("//table[@class='wpsl-opening-hours']//text()").extract()
        ```


Discussion:
This can be converted as it returns 100 closest points and allows 500 mile/km search radius. I'll convert it :)

Resolving patch:
diff --git a/locations/spiders/bashas.py b/locations/spiders/bashas.py
deleted file mode 100644
--- a/locations/spiders/bashas.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import html
-import json
-
-import scrapy
-
-from locations.dict_parser import DictParser
-from locations.hours import OpeningHours
-
-
-class BashasSpider(scrapy.spiders.SitemapSpider):
-    name = "bashas"
-    item_attributes = {
-        "brand": "Bashas'",
-        "brand_wikidata": "Q4866786",
-    }
-
-    download_delay = 0.2
-    sitemap_urls = ["https://www.bashas.com/wpsl_stores-sitemap.xml"]
-    sitemap_rules = [("/stores/", "parse_store")]
-
-    def parse_store(self, response):
-        script = response.xpath("//script[@id='wpsl-js-js-extra']/text()").extract_first()
-        open_brace = script.find('"locations":[{') + 13
-        close_brace = script.rfind("}]}") + 1
-        store_json = json.loads(script[open_brace:close_brace])
-        hours = response.xpath("//table[@class='wpsl-opening-hours']//text()").extract()
-
-        item = DictParser.parse(store_json)
-        item["street_address"] = item.pop("addr_full", None)
-        item["country"] = "US"
-        item["name"] = html.unescape(store_json["store"])
-        item["website"] = response.url
-        item["phone"] = response.xpath("//div[@class='wpsl-contact-details']//text()").extract()[1]
-        item["opening_hours"] = self.parse_hours(hours)
-
-        yield item
-
-    @staticmethod
-    def parse_hours(hours):
-        opening_hours = OpeningHours()
-
-        days = hours[0::2]
-        times = hours[1::2]
-
-        for day, time_range in zip(days, times):
-            open_time, close_time = time_range.split(" - ")
-            opening_hours.add_range(day=day[0:2], open_time=open_time, close_time=close_time, time_format="%I:%M %p")
-
-        return opening_hours
diff --git a/locations/spiders/bashas_us.py b/locations/spiders/bashas_us.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/bashas_us.py
@@ -0,0 +1,22 @@
+from html import unescape
+
+from locations.categories import Categories
+from locations.storefinders.wp_store_locator import WPStoreLocatorSpider
+
+
+class BashasUSSpider(WPStoreLocatorSpider):
+    name = "bashas_us"
+    item_attributes = {
+        "brand": "Bashas'",
+        "brand_wikidata": "Q4866786",
+        "extras": Categories.SHOP_SUPERMARKET.value,
+    }
+    allowed_domains = ["www.bashas.com"]
+    searchable_points_files = ["us_centroids_iseadgg_458km_radius.csv"]
+    search_radius = 500
+    max_results = 100
+    time_format = "%I:%M %p"
+
+    def parse_item(self, item, location):
+        item["name"] = unescape(item["name"])
+        yield item


Test patch: