Skip to content

amzSear v3: Updated selectors, ASIN-based API, product details, reviews, and modern dependencies - #37

Open
v1b3coder wants to merge 14 commits into
asherAgs:masterfrom
v1b3coder:master
Open

amzSear v3: Updated selectors, ASIN-based API, product details, reviews, and modern dependencies#37
v1b3coder wants to merge 14 commits into
asherAgs:masterfrom
v1b3coder:master

Conversation

@v1b3coder

@v1b3coder v1b3coder commented Apr 26, 2026

Copy link
Copy Markdown

Summary

This fork brings amzSear up to date with modern Amazon and modern Python. It fixes broken search functionality, adds the ability to look up products by ASIN, and introduces new classes for fetching detailed product information and customer reviews.

Note: This PR is a superset of changes from #35 by @Foadsf, which served as the starting point. On top of those fixes, this branch adds further updates, new features, and a refined CLI.

What's New

It Works Again

  • Updated selectors to match Amazon's current HTML structure — search results now work reliably
  • Modernized HTTP layer — switched from the deprecated urllib to requests, with proper headers and timeouts
  • Updated dependencies to versions that work on current Python 3 installations
  • Fixed multi-page searches — results from all pages are now collected properly

New: Look Up Any Product by ASIN

You can now fetch detailed product information directly:

$ amzsear -a B00006IFHD

This returns the brand, full title, product bullet points, technical specifications, review count, average rating, and image URLs — all extracted from the product page.

New: Customer Reviews

A new AmzReviews class lets you extract customer review data programmatically: reviewer name, star rating, review text, date, verified purchase status, helpful votes, and attached images.

CLI Improvements

  • ASIN-based indexing — search results are now keyed by the product's ASIN, making them stable and easy to reference
  • -a/--asin — look up a product directly by ASIN
  • -v/--verbose and -j/--json — simpler flags replace the old --output option
  • -b/--browser — open the product page in your browser (replaces the inverted --dont-open)
  • --version — see the installed version
  • Better error messages — network failures and invalid keys now print clear errors with proper exit codes

New Region Support

  • Added UAE (AE) to the list of supported Amazon regions

Under the Hood

  • CSS selectors moved to a dedicated selectors.py file for easier maintenance
  • All public methods now have proper docstrings
  • Code follows PEP 8 style
  • Products are deduplicated across multi-page searches
  • Affiliate tracking tag removed from search queries

Breaking Changes

  • Product indices are now ASINs (10-character strings) instead of sequential numbers. Use rget() for positional access as before.
  • --output is replaced by -v and -j flags; CSV export has been removed (use -j for JSON instead).
  • -i/--item renamed to -s/--select.
  • -d/--dont-open replaced by -b/--browser (inverted logic — now you opt in to opening the browser).

Foadsf and others added 14 commits October 3, 2025 21:21
Add CLI flag -P/--product to fetch product details directly by ASIN,
bypassing search. Includes new AmzProductDetails, AmzReviews, and
selectors modules for parsing product pages. Supports all output
formats (short, verbose, JSON, CSV).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add single fetch_html() function in core/__init__.py used by both
AmzSear (search) and AmzProduct (product details). Remove duplicate
request code and consolidate headers into REQUEST_HEADERS constant.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace UUID (DOM element ID) with ASIN as collection key
- Deduplicate search results by ASIN, keeping first occurrence
- Display ASIN column in search output
- The -i flag now accepts ASIN for item selection

UUID was Amazon's internal DOM identifier with no practical use.
ASIN is the universal product identifier that works with -P flag.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
CLI changes:
- -i/--item accepts both ASIN and numeric index (0-based position)
- Replace -d/--dont-open with -b/--browser (browser no longer opens by default)
- CSV output uses 'asin' as first column instead of legacy '_index'
- Add -P/--product documentation to help text

Bug fixes:
- Fix missing 'elif' for verbose output handler
- Fix typo in comment ('quite' -> 'quiet')

Documentation:
- Update README.md with ASIN-based output examples
- Update docs/cli/README.md with new flags and examples
- Add Example 7 for direct product lookup by ASIN

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace -P/--product with -a/--asin for ASIN lookup
- Replace -i/--item with -s/--select for result selection
- Update documentation to reflect new flag names

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace -o {short,verbose,json} with independent -v and -j flags
- -v shows full details, -j outputs JSON, combinable as -v -j
- Remove CSV and quiet output formats
- Fix verbose output: full-length values, proper formatting
- Fix region bug: pass region to AmzProduct for correct domain URLs
- Update documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace silent None returns in fetch_html with explicit FetchError
exceptions. Store fetch errors in AmzProduct._fetch_error and display
them in CLI output instead of silently showing no data.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix shared mutable class attribute bug in AmzBase (_all_attrs)
- Fix incorrect fallback import paths in AmzBase.py and AmzRating.py
- Switch from urllib to requests for HTTP requests
- Add @functools.wraps to decorators to preserve metadata
- Fix None/True comparisons (use 'is None' and truthy checks)
- Fix division by zero risk in AmzRating.get_perc()
- Fix inefficient __len__ in AmzBase (use generator)
- Move docstrings inside functions per Python convention
- Add --version/-V flag to CLI
- Add exit codes and error handling to CLI
- Add __version__ to package
- Fix regex escape warnings (use raw strings)
- Remove unused lxml.html.clean import
- URL-encode query strings in build_url() for security
- Bump version to 2.0.2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The products variable was being reassigned on each loop iteration
instead of accumulating results. Now uses extend() to collect
products from all pages.

Bump version to 3.0.1

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants