I’m using Python 2.7, and what I’m trying to do is this:
I have the following JSON String.
http://www.ows.newegg.com/Products.egg/N82E16822148992
In this string, there are multiple values called FinalPrice. I’m trying to get the MAIN FinalPrice for the item in question (the item here is #N82E16822148992). The main FinalPrice would be the one that refers to the main item on the page. The corresponding page for this JSON page is http://www.newegg.com/Product/Product.aspx?Item=N82E16822148992.
So, would there be any way to grab the FinalPrice I need out of usually around 10 FinalPrices (I say usually because I’ve only tested the number of FinalPrices with 3 links and they’re all ten)? I thought maybe I could find a way by using the product name to find the location of the final price, but there’s always page-specific characters between the name of the product and the FinalPrice.
What can I do about this?
P.S Here’s what I’ve tried:
I’ve looked at Python.org’s JSON documentation, but it didn’t help me much with finding the specific FinalPrice (or maybe I was just looking at it wrong?)
I’ve tried making the whole JSON page a string, and using some string manipulation (s.find, s[a:b]) to get the FinalPrice I need, but I couldn’t find a way to get any FinalPrice besides the first one.
I’ve searched on Google and Stack Overflow for a proper answer to this.
That’s about all I’ve done so far.
The main top-level data structure of the JSON data you linked has only one
FinalPricekey, so it should be trivial to get this information:You can use the
pprint.pprintfunction to get a quick feel of the data structure:You can then see that the other
FinalPriceentries are part of theShoppingInsight->PromotionItemsstructure, which is a list: