-
Notifications
You must be signed in to change notification settings - Fork 203
/
eightyfour_lumber_us.py
49 lines (42 loc) · 1.56 KB
/
eightyfour_lumber_us.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
import scrapy
from locations.hours import OpeningHours
from locations.items import Feature
DAYS = [
"Monday",
"Tuesday",
"Wednsday", # sic
"Thursday",
"Friday",
"Saturday",
"Sunday",
]
class EightyfourLumberUSSpider(scrapy.Spider):
name = "eightyfour_lumber_us"
item_attributes = {"brand": "84 Lumber", "brand_wikidata": "Q4644779"}
allowed_domains = ["84lumber.com"]
start_urls = ["https://www.84lumber.com/umbraco/surface/StoreSupport/StoreSearch?radius=10000"]
def parse(self, response):
data = json.loads(json.loads(response.text))
for row in data:
opening_hours = OpeningHours()
for day in DAYS:
if not row[f"{day}HoursCheck"]:
continue
open_time = row[f"{day}OpenHours"]
close_time = row[f"{day}CloseHours"]
opening_hours.add_range(day[:2], open_time, close_time, "%I:%M%p")
properties = {
"ref": row["StoreNumber"],
"lat": row["Latitude"],
"lon": row["Longitude"],
"name": row["Name"],
"website": f'https://www.84lumber.com/store-locator/store-detail/?storeId={row["StoreNumber"]}',
"street_address": row["Address"],
"city": row["City"],
"state": row["State"],
"postcode": row["Zip"],
"phone": row["Phone"],
"opening_hours": opening_hours.as_opening_hours(),
}
yield Feature(**properties)