Repository: alltheplaces/alltheplaces

Issue:
Chuy's
https://www.chuys.com/locations


Discussion:
I'll take this one
@meganychan Hello, thanks for reaching out. I've labeled issues in the repository that are good options for creating your first spider. The ultimate goal is to scrape the URL linked above (or a better one if you find it) for [location information](https://github.com/alltheplaces/alltheplaces/blob/master/DATA_FORMAT.md) regarding the business. The project is built using [scrapy](https://docs.scrapy.org/en/latest/), so there is more documentation there the can also assist you as well. Feel free to comb through the spiders in the [locations folder](https://github.com/alltheplaces/alltheplaces/tree/master/locations) for guidance on completed spiders, see [university_maryland_medical_system.py](https://github.com/alltheplaces/alltheplaces/blob/43ae0183827f340925555029e26b3810730be268/locations/spiders/university_maryland_medical_system.py) and [credit_agricole.py](https://github.com/alltheplaces/alltheplaces/blob/c0b9dfe7379e8fef192fc319fcebe2b10b352204/locations/spiders/credit_agricole.py) as examples. If you find an issue that you think looks interesting, let me know and I will assign it to you, and feel free to reach out if you have more questions.

Resolving patch:
diff --git a/locations/spiders/chuys.py b/locations/spiders/chuys.py
new file mode 100644
--- /dev/null
+++ b/locations/spiders/chuys.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+import scrapy
+import re
+from urllib.parse import urljoin
+from locations.items import GeojsonPointItem
+
+
+class ChuysSpider(scrapy.Spider):
+    name = "chuys"
+    allowed_domains = ["www.chuys.com"]
+    start_urls = ("https://www.chuys.com/locations",)
+
+    def parse(self, response):
+        data = response.xpath(
+            '//script[@type="text/javascript"][contains(text(), "new google.maps.LatLng")]/text()'
+        ).extract_first()
+
+        re_location_id = r"markers\[(\d+)\]"
+        location_ids = re.findall(re_location_id, data)
+
+        for location_id in location_ids:
+            re_pattern_store_info = (
+                rf"infoWindowContent{location_id}\s\+=(?!.*Coming Soon).+;"
+            )
+            store_info = re.findall(re_pattern_store_info, data)
+
+            name = re.search(r"<strong>(.*?)</strong>", store_info[0]).group(1)
+            addr_full = re.search(r"<br.*>(.*?)'", store_info[1]).group(1).strip()
+            locality = re.search(r"<br.*>(.*?)'", store_info[2]).group(1)
+            phone = re.search(r"<br.*>(.*?)'", store_info[3]).group(1)
+            website = urljoin(
+                "https://www.chuys.com",
+                re.search(r"href=\"(.*?)\"", store_info[4]).group(1),
+            )
+
+            re_coordinates = rf"latLng{location_id}.*LatLng\((.*)\)"
+            lat, lon = re.search(re_coordinates, data).group(1).split(", ")
+
+            properties = {
+                "ref": location_id,
+                "name": name,
+                "addr_full": addr_full,
+                "city": locality.split(", ")[0],
+                "state": locality.split(", ")[1].split()[0],
+                "postcode": locality.split(", ")[1].split()[1],
+                "phone": phone,
+                "website": website,
+                "lat": lat,
+                "lon": lon,
+            }
+
+            yield GeojsonPointItem(**properties)


Test patch: