Repository: alltheplaces/alltheplaces

Issue:
Norfa (LT)

### Brand name

Norfa

Lithuanian supermarket chain

### Wikidata ID

Q1998983
https://www.wikidata.org/wiki/Q1998983
https://www.wikidata.org/wiki/Special:EntityData/Q1998983.json

### Store finder url(s)
https://www.norfa.lt/parduotuves/
Official Url(s): http://www.norfa.lt/
- [x] I have run the below and if anything in generated, added it.
- [x] 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=Q1998983 http://www.norfa.lt/`
```
```


Discussion:
HTML Parsing

```
<html>
<body>
<!--StartFragment-->
<div class="c-shop-list">
--
  |  
  | <div class="c-shop shop-4">
  | <div class="c-shop__size">
  | <img src="https://www.norfa.lt/assets/Visos-svetaines-foto/Images/shop-h.svg" alt="">
  | </div>
  | <div class="c-shop__location">Savanorių pr. 176, Vilnius (Vingis)</div>
  | <div class="c-shop__hours">I-VI 6.30-22.00 VII 9.00-21.00</div>
  | <a href="#" class="c-shop__show-on-map" data-id="4">
  | Rodyti žemėlapyje<i class="icon-pin"></i>
  | </a>
  | <div class="c-expander-content h-expand-4">
  | <div class="c-shop-deatiled">
  | <img src="" alt="">
  |  
  | <p>Mob. tel. <a href="tel:868543772">+37068543772</a> (skambinti d.d. 8-12val. ir 13-17val.)</p><p></p>
  |  
  |  
  | <h3>Parduotuvėje yra:</h3>
  | <table class="c-services-table">
  |  
  | <tr>
  |  
  | <td><i class="icon-fresh-food"></i></td>
  | <td>Karštų gaminių skyrius</td>
  |  
  | <td><i class="icon-fish"></i></td>
  | <td>Šviežios žuvies skyrius</td>
  |  
  | </tr>
  |  
  | </table>
  |  

<!--EndFragment-->
</body>
</html><div class="c-shop-list">
                            
                                <div class="c-shop shop-4">
                                    <div class="c-shop__size">
                                        <img src="https://www.norfa.lt/assets/Visos-svetaines-foto/Images/shop-h.svg" alt="">
                                    </div>
                                    <div class="c-shop__location">Savanorių pr. 176, Vilnius (Vingis)</div>
                                    <div class="c-shop__hours">I-VI 6.30-22.00 VII 9.00-21.00</div>
                                    <a href="[#](https://www.norfa.lt/parduotuves/#)" class="c-shop__show-on-map" data-id="4">
                                        Rodyti žemėlapyje<i class="icon-pin"></i>
                                    </a>
                                    <div class="c-expander-content h-expand-4">
                                        <div class="c-shop-deatiled">
                                            <img src="" alt="">

                                            <p>Mob. tel. <a href="tel:868543772">+37068543772</a> (skambinti d.d. 8-12val. ir 13-17val.)</p><p></p>

                                            
                                                <h3>Parduotuvėje yra:</h3>
                                                <table class="c-services-table">
                                                    
                                                        <tr>
                                                            
                                                                <td><i class="icon-fresh-food"></i></td>
                                                                <td>Karštų gaminių skyrius</td>
                                                            
                                                                <td><i class="icon-fish"></i></td>
                                                                <td>Šviežios žuvies skyrius</td>
                                                            
                                                        </tr>
                                                    
                                                </table>

```

Resolving patch:
diff --git a/locations/hours.py b/locations/hours.py
--- a/locations/hours.py
+++ b/locations/hours.py
@@ -170,6 +170,25 @@
     "יום ראשון": "Su",
 }
 
+DAYS_LT = {
+    "pirmadienis": "Mo",
+    "antradienis": "Tu",
+    "trečiadienis": "We",
+    "ketvirtadienis": "Th",
+    "penktadienis": "Fr",
+    "šeštadienis": "Sa",
+    "sekmadienis": "Su",
+    "I": "Mo",
+    "II": "Tu",
+    "III": "We",
+    "IV": "Th",
+    "V": "Fr",
+    "VI": "Sa",
+    "VII": "Su",
+    "Vi": "Sa",
+    "Vii": "Su",
+}
+
 DAYS_SE = {
     "Måndag": "Mo",
     "Mån": "Mo",
diff --git a/locations/spiders/norfa_lt.py b/locations/spiders/norfa_lt.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/norfa_lt.py
@@ -0,0 +1,49 @@
+import chompjs
+from scrapy import Spider
+
+from locations.hours import DAYS_LT, OpeningHours
+from locations.items import Feature
+
+
+class NorfaLT(Spider):
+    name = "norfa_lt"
+    start_urls = ["https://www.norfa.lt/parduotuves/"]
+    item_attributes = {"brand": "Norfa", "brand_wikidata": "Q1998983"}
+
+    def parse(self, response):
+        js = (
+            response.xpath("//script[contains(text(), '_markers_data_main ')]")
+            .get()
+            .replace(" var _markers_data_main = ", "")
+        )
+        data = chompjs.parse_js_object(js)
+
+        for location in response.xpath("//div[contains(@class, 'c-shop shop-')]"):
+            item = Feature()
+            item["ref"] = location.xpath("@class").get().split("c-shop shop-")[1]
+
+            for extra_data in data:
+                if str(extra_data["id"]) == item["ref"]:
+                    item["lat"] = extra_data["lat"]
+                    item["lon"] = extra_data["lang"]
+
+            item["street_address"] = location.xpath("*[@class='c-shop__location']/text()").get()
+            item["opening_hours"] = OpeningHours()
+            # I-VI 8.00-21.00 VII 10.00-20.00
+            hours_str = location.xpath("*[@class='c-shop__hours']/text()").get().replace(".", ":")
+            item["opening_hours"].add_ranges_from_string(hours_str, days=DAYS_LT)
+
+            item["phone"] = location.xpath(
+                "div/div[@class='c-shop-deatiled']/p/a[contains(@href, 'tel:')]/text()"
+            ).get()
+
+            # TODO: Is it worth mapping any of
+            # <table class="c-services-table">
+            # <td><i class="icon-fresh-food"></i></td>
+            # <td>Karštų gaminių skyrius</td>
+            # <td><i class="icon-fish"></i></td>
+            # <td>Šviežios žuvies skyrius</td>
+            # h<td><i class="icon-conditery"></i></td>
+            # <td>Norfos kepyklėlė</td>
+
+            yield item


Test patch: