Skip to content

Instantly share code, notes, and snippets.

@ewdurbin
Created October 19, 2012 17:37
Show Gist options
  • Select an option

  • Save ewdurbin/3919532 to your computer and use it in GitHub Desktop.

Select an option

Save ewdurbin/3919532 to your computer and use it in GitHub Desktop.
Cheap RAM
#!/usr/bin/env python
import requests
from pyquery import PyQuery as pq
results = []
for page in range(1,6):
url = 'http://stores.ebay.com/IT-Creations-inc/_i.html?rt=nc&_nkw=dell%2010600R&_pgn=' + str(page)
r = requests.get(url)
d = pq(r.text)
for i in range(0,47):
item = d('.li').eq(i)
title = item('.ttl').text()
price = item('.g-b').text()
url = item('.ttl a').attr("href")
if title and price:
count = title.split()[6].lstrip('(').rstrip(')')
size = title.split()[8].lstrip('(').rstrip(')')
cost = price.lstrip('$').replace(',','')
unit_cost = float(cost) / float(count)
results.append("%s,%s,%s,%s,%s" % (round(unit_cost, 2), count, size, cost, url))
print "\n".join(sorted(results))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment