import json

import scrapy

from locations.categories import Categories, apply_category
from locations.structured_data_spider import StructuredDataSpider


class FirstHotelsSpider(StructuredDataSpider):
    name = "first_hotels"
    item_attributes = {"brand": "First Hotels", "brand_wikidata": "Q11969007"}
    start_urls = ["https://www.firsthotels.com/general-info/about-first-hotels/map-of-hotels/"]

    def parse(self, response):
        hotels = json.loads(response.xpath('//*[@class="allhotels"]/div/@data-pois').get())
        for hotel in hotels:
            yield scrapy.Request(url="https://www.firsthotels.com" + hotel["url"], callback=self.parse_sd)

    def post_process_item(self, item, response, ld_data, **kwargs):
        coords = ld_data["hasMap"].split("@")[1]
        item["name"] = item["name"].strip()
        item["lat"] = coords.split(",")[0]
        item["lon"] = coords.split(",")[1]
        apply_category(Categories.HOTEL, item)
        yield item

348c4cab0b363014d0204f7ad0ce667368d91749
<mask token>


class FirstHotelsSpider(StructuredDataSpider):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

<mask token>


class FirstHotelsSpider(StructuredDataSpider):
    <mask token>
    <mask token>
    <mask token>

    def parse(self, response):
        hotels = json.loads(response.xpath(
            '//*[@class="allhotels"]/div/@data-pois').get())
        for hotel in hotels:
            yield scrapy.Request(url='https://www.firsthotels.com' + hotel[
                'url'], callback=self.parse_sd)

    def post_process_item(self, item, response, ld_data, **kwargs):
        coords = ld_data['hasMap'].split('@')[1]
        item['name'] = item['name'].strip()
        item['lat'] = coords.split(',')[0]
        item['lon'] = coords.split(',')[1]
        apply_category(Categories.HOTEL, item)
        yield item

<mask token>


class FirstHotelsSpider(StructuredDataSpider):
    name = 'first_hotels'
    item_attributes = {'brand': 'First Hotels', 'brand_wikidata': 'Q11969007'}
    start_urls = [
        'https://www.firsthotels.com/general-info/about-first-hotels/map-of-hotels/'
        ]

    def parse(self, response):
        hotels = json.loads(response.xpath(
            '//*[@class="allhotels"]/div/@data-pois').get())
        for hotel in hotels:
            yield scrapy.Request(url='https://www.firsthotels.com' + hotel[
                'url'], callback=self.parse_sd)

    def post_process_item(self, item, response, ld_data, **kwargs):
        coords = ld_data['hasMap'].split('@')[1]
        item['name'] = item['name'].strip()
        item['lat'] = coords.split(',')[0]
        item['lon'] = coords.split(',')[1]
        apply_category(Categories.HOTEL, item)
        yield item

import json
import scrapy
from locations.categories import Categories, apply_category
from locations.structured_data_spider import StructuredDataSpider


class FirstHotelsSpider(StructuredDataSpider):
    name = 'first_hotels'
    item_attributes = {'brand': 'First Hotels', 'brand_wikidata': 'Q11969007'}
    start_urls = [
        'https://www.firsthotels.com/general-info/about-first-hotels/map-of-hotels/'
        ]

    def parse(self, response):
        hotels = json.loads(response.xpath(
            '//*[@class="allhotels"]/div/@data-pois').get())
        for hotel in hotels:
            yield scrapy.Request(url='https://www.firsthotels.com' + hotel[
                'url'], callback=self.parse_sd)

    def post_process_item(self, item, response, ld_data, **kwargs):
        coords = ld_data['hasMap'].split('@')[1]
        item['name'] = item['name'].strip()
        item['lat'] = coords.split(',')[0]
        item['lon'] = coords.split(',')[1]
        apply_category(Categories.HOTEL, item)
        yield item

import json

import scrapy

from locations.categories import Categories, apply_category
from locations.structured_data_spider import StructuredDataSpider


class FirstHotelsSpider(StructuredDataSpider):
    name = "first_hotels"
    item_attributes = {"brand": "First Hotels", "brand_wikidata": "Q11969007"}
    start_urls = ["https://www.firsthotels.com/general-info/about-first-hotels/map-of-hotels/"]

    def parse(self, response):
        hotels = json.loads(response.xpath('//*[@class="allhotels"]/div/@data-pois').get())
        for hotel in hotels:
            yield scrapy.Request(url="https://www.firsthotels.com" + hotel["url"], callback=self.parse_sd)

    def post_process_item(self, item, response, ld_data, **kwargs):
        coords = ld_data["hasMap"].split("@")[1]
        item["name"] = item["name"].strip()
        item["lat"] = coords.split(",")[0]
        item["lon"] = coords.split(",")[1]
        apply_category(Categories.HOTEL, item)
        yield item
