I am scraping a json api using scrapy and want to loop through the offers and then the outcomes as shown in the screenshot below. I am getting to the offers OK but then not sure what to write for the get() as its unlabeled. Everything I have tried leads to an error of 'list' object has no attribute get.
My code is below:
import scrapy
import json
class DkSpider(scrapy.Spider):
name = 'dk'
allowed_domains = ['sportsbook.draftkings.com']
start_urls = ['https://sportsbook.draftkings.com//sites/US-SB/api/v4/eventgroups/88670846/categories/583/subcategories/4991']
def parse(self, response):
items = json.loads(response.body)
cats = items.get('eventGroup').get('offerCategories')
for cat in cats:
groups = str(cat.get('name'))
if groups == "Player Props":
subcats = cat.get('offerSubcategoryDescriptors')
for subcat in subcats:
markets = str(subcat.get('name'))
if markets == "Points":
games = subcat.get('offerSubcategory').get('offers')
for game in games:
outcomes = game.get('outcomes')
