summaryrefslogtreecommitdiff
path: root/part_search_cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'part_search_cmd.py')
-rw-r--r--part_search_cmd.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/part_search_cmd.py b/part_search_cmd.py
new file mode 100644
index 0000000..76f2c28
--- /dev/null
+++ b/part_search_cmd.py
@@ -0,0 +1,24 @@
+import octopart
+
+search = octopart.ResistorSearch()
+search['resistance'] = 1000
+search['package_type'] = octopart.PackageType.smd
+search['case'] = '1206'
+search['seller'] = 'farnell'
+
+search_response = octopart.resistor_search(search)
+
+print "Hits: {}".format(search_response.hits)
+
+for search_result in search_response.results:
+ p = search_result.item
+
+ print "{}: Snippet: {}".format(p.uid, search_result.snippet)
+# print "Uid: {}".format(p.uid)
+# print "Offers: "
+# for o in p.offers:
+# print " SKU: {}".format(o.sku)
+# for (currency, prices) in o.prices.iteritems():
+# for price in prices:
+# print " {}: {}@{}".format(currency, price.amount, price.quantity)
+# pass