Comparing the price:size ratio of SSD drives Amazon

from urllib.request import Request, urlopen from lxml import html from urllib.parse import quote_plus # Python3 import re keyword = 'SSD' regex = re.compile(r"(?:\s?)(\d+)[GB|TB]") url = 'https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=' + quote_plus(keyword) # Adding user agent header is required to avoid "Error 503: Service unavailable" headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' } req = Request(url, headers=headers) content = urlopen(req).read() tree = html.fromstring(content) name = '' product_data = [] for item in tree.xpath('//div[@class="s-item-container"]'): gigabytes = 0 # Product name name_el = item.xpath('.//div[contains(@class, "s-list-title-medium")]/a/@title') if len(name_el) == 1: name = name_el[0] gigabytes_list = regex.findall(name) if gigabytes_list: gigabytes = int(gigabytes_list[0]) if gigabytes < 10: gigabytes *= 1000 # Products star rating stars = item.xpath('.//span[contains(@class, "a-icon-alt")]/text()') if 'Prime' in stars: stars.remove('Prime') if len(stars) == 1: stars = stars[0].split(' ',1)[0] + ' stars' else: stars = '' # Number of product reviews reviews = item.xpath('.//div[contains(@class, "a-span5")]/div[contains(@class, "a-spacing-mini")]/a/text()') if len(reviews) == 1: reviews = reviews[0].replace(',', '') + ' reviews' else: reviews = '' # Product price price_el = item.xpath('.//div[contains(@class, "a-span7")]/div/a/span/@aria-label') if price_el: price = price_el[0][1:] # Product price per gigabyte if price and gigabytes != 0: price_per_gb = float(price) / gigabytes else: price_per_gb = 99999999 # Assemble product data product_data.append((price_per_gb, "{name} ({stars}, {reviews}): {price}$; $/GB: {price_per_gb:.5f}".format( name = name, stars = stars, reviews = reviews, price = price, price_per_gb = price_per_gb ))) product_data.sort() print("Products ranked by $/GB in ascending order:\n") for _, product in product_data: print(product) """ Products ranked by $/GB in ascending order: Mushkin REACTOR 1TB Internal Solid State Drive (SSD) 2.5 Inch SATA III 6Gb/s MLC 7mm MKNSSDRE1TB (4.5 stars, 332 reviews): 264.99$; $/GB: 0.26499 Crucial MX300 1TB M.2 (2280) Internal Solid State Drive - CT1050MX300SSD4 (4.6 stars, 392 reviews): 287.99$; $/GB: 0.28799 Samsung 850 EVO 500GB 2.5-Inch SATA III Internal SSD (MZ-75E500B/AM) (4.8 stars, 16023 reviews): 144.99$; $/GB: 0.28998 SanDisk Ultra II 500GB SATA III SSD - 2.5-Inch 7mm Height Solid State Drive - SDSSDHII-500G-G25 (4.4 stars, 2648 reviews): 149.00$; $/GB: 0.29800 Crucial MX300 525GB SATA 2.5 Inch Internal Solid State Drive - CT525MX300SSD1 (4.6 stars, 2305 reviews): 156.69$; $/GB: 0.29846 Crucial MX300 525GB SATA 2.5 Inch Internal Solid State Drive - CT525MX300SSD1 (4.6 stars, 2305 reviews): 156.69$; $/GB: 0.29846 Aireye 120GB SATA III 2.5-Inch 6.0Gb/s Solid State Drive (SSD)-S1 (4.6 stars, 86 reviews): 54.99$; $/GB: 0.29998 Gloway 240GB SSD Drive SATA III Internal Solid State Drive 3 Years Warranty MLC with Cache (1 stars, 2 reviews): 78.88$; $/GB: 0.29998 SanDisk 500GB Ultra 3D NAND SATA III SSD - 2.5-inch Solid State Drive - SDSSDH3-500G-G25 (4.3 stars, 10 reviews): 149.99$; $/GB: 0.32866 WD Blue 250GB Internal SSD Solid State Drive - SATA 6Gb/s 2.5 Inch - WDS250G1B0A (4.6 stars, 692 reviews): 89.99$; $/GB: 0.35996 Crucial BX300 240GB SATA 2.5 Inch Internal Solid State Drive - CT240BX300SSD1 (5 stars, 1 reviews): 89.99$; $/GB: 0.37496 Samsung 850 PRO - 512GB - 2.5-Inch SATA III Internal SSD (MZ-7KE512BW) (4.7 stars, 3207 reviews): 209.99$; $/GB: 0.41014 Silicon Power 120GB SSD S55 TLC 7mm (0.28") Internal Solid State Drive (SP120GBSS3S55S25AE) (4.5 stars, 211 reviews): 49.99$; $/GB: 0.41658 ADATA SU800 128GB 3D-NAND 2.5 Inch SATA III High Speed up to 560MB/s Read Solid State Drive (ASU800SS-128GT-C) (4.5 stars, 1123 reviews): 56.68$; $/GB: 0.44281 KingSpec SSD 180GB 2.5" SATA3 3D TLC Internal SSD Hard Drive for Desktop, Laptop, Macbook (Q-180) (, ): 56.68$; $/GB: 0.44281 250GB Samsung 850 EVO Series SATA 6Gbps SSD Solid State Disk 2.5-inch powered by 3D V-Nand (4.9 stars, 21 reviews): 112.97$; $/GB: 0.45188 Samsung 960 EVO Series - 250GB PCIe NVMe - M.2 Internal SSD (MZ-V6E250BW) (4.7 stars, 672 reviews): 117.60$; $/GB: 0.47040 Samsung 960 EVO Series - 250GB PCIe NVMe - M.2 Internal SSD (MZ-V6E250BW) (4.7 stars, 672 reviews): 117.60$; $/GB: 0.47040 Kingston Digital, Inc. 120GB A400 SATA 3 2.5 Solid State Drive SA400S37/120G 2.5" SA400S37/120G (4.7 stars, 139 reviews): 58.99$; $/GB: 0.49158 SanDisk SSD PLUS 120GB Solid State Drive (SDSSDA-120G-G26) [Newest Version] (4.6 stars, 1018 reviews): 59.75$; $/GB: 0.49792 Kingston Digital 120GB SSDNow UV400 SATA 3 2.5" Solid State Drive SUV400S37/120G (4.7 stars, 747 reviews): 62.95$; $/GB: 0.52458 PNY CS1311 120GB 2.5” SATA III Internal Solid State Drive (SSD) - (SSD7CS1311-120-RB) (4.6 stars, 1457 reviews): 62.99$; $/GB: 0.52492 DREVO X1 Pro 64GB SSD Internal Solid State Drive 2.5-Inch SATA3 MLC High Performance (, ): 579.97$; $/GB: 0.57997 Kingfast SSD 240GB - Solid State Drive with Incredible Sequential Read/Write Up to 550MB/s, 2.5 Inch SATAIII Faster Boot-ups, Shutdowns, Data Transfers Internal Solid State Drive for Desktop PC Laptop (5 stars, 6 reviews): 579.97$; $/GB: 0.57997 Samsung 960 PRO Series - 1TB PCIe NVMe - M.2 Internal SSD (MZ-V6P1T0BW) (4.6 stars, 253 reviews): 579.97$; $/GB: 0.57997 Toshiba OCZ Trion 150 480GB 2.5" 7mm SATA III Internal Solid State Drive TRN150-25SAT3-480G (4.6 stars, 691 reviews): 579.97$; $/GB: 0.57997 Samsung 850 EVO - 120GB - 2.5-Inch SATA III Internal SSD (MZ-75E120B/AM) (4.7 stars, 814 reviews): 79.95$; $/GB: 0.66625 Samsung 750 EVO - 120GB - 2.5-Inch SATA III Internal SSD (MZ-750120BW) (4.6 stars, 137 reviews): 80.14$; $/GB: 0.66783 """

We see that on the top of the list are large drives of 1TB, while at the bottom are smaller drives of 120GB. The larger the drive, the cheaper it becomes per gigabyte, which is what we expected. But we see, that someone who is buying a small drive effectively pays up to 0.66783/0.26499 = 2.52 times more per gigabyte. Not only will their machine age sooner, but they may end up having less resources for the next upgrade.