Skip to content

Instantly share code, notes, and snippets.

@notexactlyawe
Created August 23, 2025 10:47
Show Gist options
  • Select an option

  • Save notexactlyawe/ca30b7374d6ef8883517ad6e574ec8d9 to your computer and use it in GitHub Desktop.

Select an option

Save notexactlyawe/ca30b7374d6ef8883517ad6e574ec8d9 to your computer and use it in GitHub Desktop.
Barcode scanning script from 2014
import sqlite3
import time
import xml.dom.minidom as xmlmd
import bottlenose
from urllib2 import HTTPError
AWS_ACCESS_KEY_ID = "AKIAJOGASDCBAWSC2LQQ"
AWS_SECRET_ACCESS_KEY = "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"
AWS_ASSOCIATE_TAG = "notexactlya05-21"
cnn = sqlite3.connect('barcodes.db')
def main():
while True:
barcode = raw_input("> ").lstrip()
if barcode == "n":
break
barcode = barcode.lstrip()
cnn.execute("INSERT INTO barcodes_temp VALUES (\"" + barcode + "\", 1)")
def error_handler(err):
ex = err['exception']
if isinstance(ex, HTTPError) and ex.code == 503:
time.sleep(random.expovariate(0.1))
return True
def process():
amazon = bottlenose.Amazon(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
AWS_ASSOCIATE_TAG, MaxQPS=0.9,
ErrorHandler=error_handler, Region="UK")
c = cnn.cursor()
c.execute("SELECT * FROM barcodes_temp")
for bar in c.fetchall(): # [0] is barcode, [1] is batch
response = amazon.ItemLookup(ItemId=bar[0], IdType="EAN", ResponseGroup="Offers", SearchIndex="VHS")
cnn.execute(
"INSERT INTO barcodes VALUES (\"" + bar[0] + "\", " + bar[1] + ", " + low_price + ", " + num_used + ", \"" + name "\")")
process()
cnn.commit()
cnn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment