Issue parsing product from new Nintendo JSON format
Closed this issue · 3 comments
Hello! It seems like Nintendo may have changed their game info JSON structure, I'm attaching a sample of it as it downloaded for me (Breath.of.the.Wild.data.txt). In the Nintendo.py scrap() method, there was an exception looking for the "product" element.
soup = BeautifulSoup(response.text, features="html.parser")
script = soup.find("script", id="NEXT_DATA")
data = json.loads(script.text)["props"]["pageProps"]["product"]
I locally replaced the block of code with this and it works:
soup = BeautifulSoup(response.text, features="html.parser")
script = soup.find("script", id="NEXT_DATA")
linkedData = json.loads(script.text)["props"]["pageProps"]["linkedData"]
sku = linkedData["sku"]
productElement = "StoreProduct:{"sku":"" + sku + "","locale":"en_US"}"
data = json.loads(script.text)["props"]["pageProps"]["initialApolloState"][productElement]
Thanks for this awesome library!
Breath of the Wild data.txt
Damn, thanks for the report. I need to check my importing logic asap.
Hi!
this should be fixed on v3.1.0.
Let me know if it works for you.
Cheers, Fede.
The latest version works perfectly. Interesting that list_switch_games() now finds around 2,000 more games! Thanks for the fix!