I am trying to start on this page (https://api.pointsbet.com/api/v2/competitions/7176/events/featured), grab the key and append it to an event api (https://api.pointsbet.com/api/v2/events/) so I can grab some data from the event api and then loop through.
I am getting the error TypeError: 'NoneType' object is not iterable and I have no idea why.
Thanks in advance!
import scrapy
import json
class PbSpider(scrapy.Spider):
name = 'pb'
allowed_domains = ['api.pointsbet.com']
start_urls = ['https://api.pointsbet.com/api/v2/competitions/7176/events/featured']
def parse(self, response):
resp = json.loads(response.body)
events = resp.get('events')
for event in events:
eventKey = event.get('key')
gameapi = f'https://api.pointsbet.com/api/v2/events/{eventKey}'
if gameapi:
yield scrapy.Request(url=gameapi, callback=self.parse)
res = json.loads(response.body)
fixedOddsMarkets = res.get('fixedOddsMarkets')
for fixedOddsMarket in fixedOddsMarkets:
market = fixedOddsMarket.get('eventName')
outcomes = fixedOddsMarket.get('outcomes')
for outcome in outcomes:
name = outcome.get('name')
price = outcome.get('price')
print(market, name, price)