Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Windows Devices

Notices

Reply
 
Thread Tools Search this Thread
Old 08-17-2022, 08:27 AM   #1
Shohreh
Zealot
Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.
 
Posts: 148
Karma: 192898
Join Date: Jan 2016
Device: none
Question [SOLVED] Cataloging books with barcode reader?

Hello,

I need to sell boxes of books.

I have a barcode scanner, Amazon* lets you query a book through its ISBN but returns a full web page that I would need to grep through to keep just the good stuff.

Before I look deeper, does someone know of a simple Windows application that can 1) grab the ISBN from the scanner, 2) look up the title + authors from a web site, and 3) add the infos into a database/spreadsheet, ready to be used on eg. eBay?

Thank you.

* https://isbn.nu/ too

Last edited by Shohreh; 08-18-2022 at 09:10 AM.
Shohreh is offline   Reply With Quote
Old 08-18-2022, 09:09 AM   #2
Shohreh
Zealot
Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.Shohreh can program the VCR without an owner's manual.
 
Posts: 148
Karma: 192898
Join Date: Jan 2016
Device: none
It works, but www.isbn.nu is missing a lot of non-English books. I'll have to find a better source (Amazon probably).

Code:
#pip install beautifulsoup4
#pip install lxml
from bs4 import BeautifulSoup
import requests
import sqlite3
import re

"""
First, scan ISBN with barcode scanner into plain text file

sqlite3.exe books.sqlite
CREATE TEMP TABLE temp_books(isbn TEXT);
.import input.txt temp_books
CREATE TABLE IF NOT EXISTS books(isbn TEXT,title TEXT, year TEXT);
INSERT INTO books(isbn) SELECT isbn FROM temp_books;
CREATE TABLE IF NOT EXISTS authors(isbn TEXT,author TEXT);
DROP TABLE temp_books;
.quit
"""

pattern_year = re.compile('(\d{4})')

db = sqlite3.connect('books.sqlite')
cursor = db.cursor()
cursor.execute('BEGIN')
with open('input.txt') as reader:
	for line in reader:
		isbn = line.strip()
		print(f"Handling {isbn}")

		url = f"https://isbn.nu/{isbn}"
		page = requests.get(url)
		soup = BeautifulSoup(page.content, 'html.parser')
		#title
		title=soup.title.string
		if title == "No Title Found":
			title = None
		print("Title=",title)
		#Year published
		for col in soup.find_all("div", {"class": "bi_row"}):
			if col.find("span", {"class": "bi_col_title"}).text == "Publication date":
				date = col.find("span", {"class": "bi_col_value"}).text 
				#Extract year
				m = pattern_year.search(date)
				if m:
					year = m.group(0) #Not (1)?
					print("Date=", year)
				else:
					print("Date not found")
				break
		cursor.execute("UPDATE books SET title= ? , year=? WHERE isbn=?", (title,year,isbn))
		
		#author(s)
		authors = soup.select("a[href*=authorx]")
		for author in authors:
			name=author.string
			author = author.string
			cursor.execute("UPDATE authors SET author= ?  WHERE isbn=?", (author,isbn))
			
cursor.execute('END')
db.commit()
db.close()

print("Done.")
Shohreh is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
bulk change selection of books with input list of scanned isbn barcode numbers alkmaar Viewer 3 10-22-2021 11:00 AM
BarCode Scanner for Calibre Pietro_S Calibre 5 09-08-2019 10:07 AM
Cataloging Audio Books And Video Books mhv260 Audiobook Hardware & Software 24 09-04-2014 07:28 AM
Anti-piracy watermark in e-books gets disassembled, it's a tiny barcode! Alexander Turcic News 30 09-08-2013 08:11 PM
Android Problem with the barcode reader app kveroneau enTourage Archive 9 12-18-2010 10:32 PM


All times are GMT -4. The time now is 08:44 AM.


MobileRead.com is a privately owned, operated and funded community.