'Scraping with beatiful soup, getting 'NoneType' error

I am working on an html parse using beautiful soup and scraping the website 'Trulia' and I had a code that worked last week and when I went to run it this week it returns the 'NoneType' error and points to this line of code " home['bathrooms']['formattedValue'], home['price']['formattedPrice']," I am pretty new to parsing and confused on why it worked fine last week and will not run now.

url = "https://www.trulia.com/graphql"

response = requests.request("POST", url, headers=headers, data=payload)
results = []
for home in json.loads(response.text)['data']['searchResultMap']['homes']:
    results.append([home['location']['fullLocation'], home['bedrooms']['formattedValue'],
          home['bathrooms']['formattedValue'], home['price']['formattedPrice'],
          home['floorSpace']['formattedDimension']])

real_estate= pd.DataFrame(data=results, columns=['Address', 'Beds', 'Baths', 'Price', 'sqft'])
print(real_estate) 

Here is the error code:

TypeError                                 Traceback (most recent call last)
C:\Users\LANDON~1\AppData\Local\Temp/ipykernel_3592/986216948.py in <module>
      5 for home in json.loads(response.text)['data']['searchResultMap']['homes']:
      6     results.append([home['location']['fullLocation'], home['bedrooms']['formattedValue'],
----> 7           home['bathrooms']['formattedValue'], home['price']['formattedPrice'],
      8           home['floorSpace']['formattedDimension']])
      9 

TypeError: 'NoneType' object is not subscriptable



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source