5 Best Affordable Vacuum for Pet Hair: Quality & Expert Picks

As pet parents, we all know the struggle: delightful furry friends bring immense joy, but they also bring an endless supply of pet hair. Finding the best affordable vacuum for pet hair doesn’t have to be a daunting task, especially when you’re trying to keep your home clean without breaking the bank. A dedicated pet hair vacuum can make a huge difference, tackling embedded fur in carpets, sweeping up loose strands on hard floors, and keeping your furniture pristine. We’ve dug deep to find the top budget-friendly options that deliver impressive performance. Our goal is to help you reclaim your home from pet hair, ensuring both cleanliness and comfort for everyone in your household.

Quick Product Comparison

.modern-product-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
font-size: 14px;
}
.modern-product-table thead th {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 10px 8px;
text-align: left;
font-weight: 600;
font-size: 15px;
border: none;
}
.modern-product-table tbody td {
padding: 10px 8px;
border-bottom: 1px solid #f0f0f0;
vertical-align: middle;
}
.modern-product-table tbody tr:last-child td {
border-bottom: none;
}
.product-name {
font-weight: 600;
color: #2d3748;
font-size: 14px;
line-height: 1.4;
max-width: 300px;
}
.product-name a {
color: inherit;
text-decoration: none;
}
.product-name a:hover {
color: #ff6b35 !important;
}
.product-image-cell {
text-align: center;
width: 80px;
}
.product-image-cell img {
width: 60px;
height: 60px;
object-fit: cover;
border-radius: 8px;
border: 2px solid #e2e8f0;
transition: transform 0.2s ease;
}
.product-image-cell img:hover {
transform: scale(1.05);
}
.price-button-cell {
text-align: center;
width: 140px;
}
.price-button {
display: inline-block;
background: linear-gradient(135deg, #ff9900 0%, #ff6b35 100%);
color: white;
padding: 8px 12px;
text-decoration: none !important;
border-radius: 6px;
font-weight: 600;
font-size: 13px;
box-shadow: 0 2px 8px rgba(255,153,0,0.3);
transition: all 0.2s ease;
white-space: nowrap;
}
.price-button:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(255,153,0,0.4);
}
@media (max-width: 768px) {
.modern-product-table {
font-size: 13px;
}
.modern-product-table thead th {
padding: 8px 6px;
font-size: 14px;
}
.modern-product-table tbody td {
padding: 8px 6px;
}
.product-name {
font-size: 13px;
max-width: 200px;
}
.product-image-cell img {
width: 50px;
height: 50px;
}
.price-button {
padding: 6px 10px;
font-size: 12px;
}
}
@media (max-width: 480px) {
.modern-product-table {
font-size: 12px;
}
.modern-product-table thead th {
padding: 6px 4px;
font-size: 13px;
}
.modern-product-table tbody td {
padding: 6px 4px;
}
.product-name {
font-size: 12px;
max-width: 150px;
}
.product-image-cell {
width: 60px;
}
.product-image-cell img {
width: 40px;
height: 40px;
}
.price-button-cell {
width: 120px;
}
.price-button {
padding: 5px 8px;
font-size: 11px;
}
}

<!–

–>

<!–

–>

<!–

–>

<!–

–>

<!–

–>

Product Image Check Price
1. Amazon Basics Lightweight Upright Bagless Vacuum for Carpet, Hard Floors, and Pet Hair…. Amazon Basics Lightweight Upright Bagless Vacuum for Carpet, Hard Floo ⭐ 4.3/5 Check Price
2. Kenmore Lightweight Cordless 2-in-1 Stick Vacuum for Hard Floors, Carpet, and Pet Hair…. Kenmore Lightweight Cordless 2-in-1 Stick Vacuum for Hard Floors, Carp ⭐ 4.1/5 Check Price
3. Eureka PowerSpeed Lightweight Bagless Upright Vacuum for Carpet, Hard Floors, and Pet Hair…. Eureka PowerSpeed Lightweight Bagless Upright Vacuum for Carpet, Hard ⭐ 4.3/5 Check Price
4. Shark Rocket Pet Plus Corded Stick Vacuum, Lightweight, Converts to Hand Vacuum for Pet Hair…. Shark Rocket Pet Plus Corded Stick Vacuum, Lightweight, Converts to Ha ⭐ 4.4/5 Check Price
5. Bissell CleanView Swivel Upright Bagless Vacuum for Powerful Pet Hair Pickup with Tools…. Bissell CleanView Swivel Upright Bagless Vacuum for Powerful Pet Hair ⭐ 4.5/5 Check Price

Our Top 5 Best Affordable Vacuum For Pet Hair Reviews – Expert Tested & Recommended

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

🏆 Best Choice

1. Amazon Basics Lightweight Upright Bagless Vacuum for Carpet, Hard Floors, and Pet Hair

Amazon Basics Lightweight Upright Bagless Vacuum for Carpet, Hard Floors, and Pet Hair

If you’re on the hunt for an incredibly lightweight and budget-friendly solution for managing pet hair, the Amazon Basics Lightweight Upright Bagless Vacuum is an excellent contender. Weighing in at just 8.4 lbs, this vacuum is designed for easy maneuverability and convenient cleaning around your home, making it one of the best affordable vacuum for pet hair options. It handles both carpets and hard floors with surprising efficiency for its price point.

Key Features That Stand Out

  • Ultra-Lightweight Design: At only 8.4 lbs, it’s exceptionally easy to carry and push, reducing fatigue during extended cleaning sessions.
  • Extended Reach: A generous 25-foot power cord allows you to clean larger areas without constantly switching outlets.
  • Versatile Cleaning Tools: Comes equipped with upholstery and crevice tools, perfect for tackling pet hair on furniture, stairs, and tight corners.
  • Large Capacity Dust Cup: Features a 1.7L dust cup, minimizing the frequency of emptying, even when dealing with significant pet shedding.
  • Bagless Operation: Easy-to-empty dust cup makes disposal quick and mess-free.

Why We Recommend It

We recommend the Amazon Basics Lightweight Upright for its remarkable balance of affordability and functionality. It punches above its weight, providing solid suction for daily pet hair cleanup without the hefty price tag. Its lightweight nature makes it a great secondary vacuum or a primary choice for smaller homes or those with multiple levels where lugging a heavy machine is impractical.

Best For

This vacuum is best for pet owners seeking a very lightweight, easy-to-use, and highly affordable solution for routine pet hair maintenance on both carpets and hard floors.

Pros and Cons

Pros:
  • Extremely lightweight (8.4 lbs) for effortless handling
  • Long 25-ft power cord for extended reach
  • Includes essential tools for versatile cleaning
  • Large dust cup reduces frequency of emptying
  • Excellent value for its budget-friendly price
Cons:
  • Suction power might not match premium, heavy-duty vacuums
  • Primarily designed for light to moderate pet hair cleanup
  • Plastic construction might feel less durable over long term

Customer Reviews

Customer Review: “So my amazing Shark finally expired and I needed some not so big vacuum for my upper level. I saw this and decided to try since people say it has strong suction. I tried it three times and so far so good. Suction is NOT as strong as the full size big vacuum that is for sure but I would say it is still good for the price.”

Customer Review: “Here’s the TL;DR review: It’s cheap. It works. Here’s the longer review: We have a couple of robot vacuums that pretty much do…whatever it is they do. My wife has a ridiculously large furball of a mainecoon. Keeping up with his shedding takes effort. A LOT of effort. That’s why we have the roo. This vacuum is definitely a good helper for quick, targeted clean-ups.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

⭐ Editor’s Choice

See also  7 Best Garden Blower & Vacuum: Expert Tested for Peak Performance

2. Kenmore Lightweight Cordless 2-in-1 Stick Vacuum for Hard Floors, Carpet, and Pet Hair

Kenmore Lightweight Cordless 2-in-1 Stick Vacuum for Hard Floors, Carpet, and Pet Hair

For those who value flexibility and quick cleanups, the Kenmore Lightweight Cordless 2-in-1 Stick Vacuum stands out as a top contender for the best affordable vacuum for pet hair. This 24V cordless marvel effortlessly transforms from a stick vacuum for floors to a handheld unit for upholstery and tight spaces, making it incredibly versatile. With features like the Easycut Nozzle, it tackles pet hair without the common hassle of tangled brushrolls.

Key Features That Stand Out

  • Cordless Convenience: Offers complete freedom of movement without being tethered to an outlet, perfect for quick daily cleanups.
  • 2-in-1 Design: Easily converts into a handheld vacuum, ideal for stairs, furniture, and car interiors where pet hair accumulates.
  • Easycut Nozzle: A unique feature that removes tangled hair and debris from the agitator with a simple button push, preventing brushroll clogs.
  • Two Speed Settings: Allows you to optimize suction for different surfaces, from delicate hard floors to more stubborn pet hair on carpets.
  • Decent Run Time: Provides up to 45 minutes of continuous suction on low mode, sufficient for most small to medium-sized homes.

Why We Recommend It

We’re impressed by the Kenmore Cordless Stick Vacuum’s blend of cordless freedom and pet-specific features at an affordable price. The Easycut Nozzle is a game-changer for pet owners, saving time and frustration from constantly untangling hair. Its versatility ensures that no pet hair-laden spot in your home goes uncleaned.

Best For

This vacuum is best for pet owners who need a versatile, lightweight, and cordless solution for everyday pet hair maintenance on various surfaces, especially those tired of tangled brushrolls.

Pros and Cons

Pros:
  • Excellent cordless flexibility for quick cleaning
  • Innovative Easycut Nozzle prevents hair tangles
  • Versatile 2-in-1 design (stick and handheld)
  • Good battery life for a cordless model
  • Lightweight and easy to store
Cons:
  • Battery life may be shorter on high suction mode
  • Smaller dust bin capacity requires more frequent emptying
  • Suction might be less intense than a corded upright for deep cleaning

Customer Reviews

Customer Review: “Great quality product. Easy to use; lightweight….good suction, good battery life…..no cords to trip over (I’m a senior living alone and vacuum cords are easy to tangle and trip over). Great to have handheld vac too to take to car or for small pieces of upholstered furniture or indoor windowsills.”

Customer Review: “Lightweight, cleans well, great suction, perfect on stairs, you can use small vacuum on furniture/auto/hard to get to areas. Works great on area rugs and anywhere you need a quick and easy clean yet can handle larger areas as well. I highly recommend this product.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

💰 Best Budget

3. Eureka PowerSpeed Lightweight Bagless Upright Vacuum for Carpet, Hard Floors, and Pet Hair

Eureka PowerSpeed Lightweight Bagless Upright Vacuum for Carpet, Hard Floors, and Pet Hair

If powerful suction is your priority but you’re working with a tight budget, the Eureka PowerSpeed Lightweight Bagless Upright Vacuum is a fantastic find. It proves that you don’t need to spend a fortune to get effective pet hair removal. This vacuum, often lauded as the best affordable vacuum for pet hair, boasts a strong 960-watt motor that delivers consistent suction across multiple floor types, all while remaining surprisingly lightweight.

Key Features That Stand Out

  • Powerful 960-Watt Motor: Delivers robust and consistent suction, making it highly effective at picking up pet hair, dander, and dirt.
  • Remarkably Lightweight: Weighing just 10 pounds, it’s easy to push, pull, and carry around your home, including up and down stairs.
  • Multi-Surface Cleaning: Transitions smoothly between hardwood, tile, area rugs, and wall-to-wall carpets, thanks to its powerful brushroll.
  • Extra-Large Dust Cup: Features a generous 2.6-liter capacity dust cup, allowing for longer cleaning sessions without frequent interruptions for emptying.
  • Easy-Empty Dust Bin: The flip-to-empty design ensures quick, clean, and mess-free disposal of collected debris and pet hair.

Why We Recommend It

We confidently recommend the Eureka PowerSpeed for its exceptional suction power at an unbeatable price point. It tackles tough pet hair messes with ease, making it a reliable workhorse for busy pet households. The combination of strong performance, lightweight design, and a large dust cup makes it an incredible value.

Best For

This vacuum is best for pet owners who need powerful, deep-cleaning suction for heavily shedding pets on various floor types, all within a strict budget.

Pros and Cons

Pros:
  • Outstanding suction power for pet hair
  • Extremely lightweight for an upright vacuum
  • Large dust cup means less frequent emptying
  • Effective on both carpets and hard floors
  • Exceptional value for its low price
Cons:
  • Corded operation can limit reach
  • Might feel less premium in build quality
  • Can be a bit loud during operation

Customer Reviews

Customer Review: “My previous vacuum was by a very popular brand, and it was expensive. It had every feature that you could imagine and worked as an upright, canister, and handheld unit. I had it for years and hated it. Why? Because it was very heavy, unwieldy, and bulky. None of the accessories were mounted on the vacuum. I am so glad I got this Eureka PowerSpeed, it’s light and powerful!”

Customer Review: “I am close to 80 years old and I have had about every brand of vacuum on the market. My last vacuum weight 16 lb. and was hard to maneuver. I saw this Eureka power speed model NEU180D which was 10 lb. and said it had great suction, with a turbo brush. I am so glad I got it. I have 3 large bird cages and it cleans up the mess wonderfully.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

4. Shark Rocket Pet Plus Corded Stick Vacuum, Lightweight, Converts to Hand Vacuum for Pet Hair

Shark Rocket Pet Plus Corded Stick Vacuum, Lightweight, Converts to Hand Vacuum for Pet Hair

The Shark Rocket Pet Plus Corded Stick Vacuum is a powerhouse in a slender package, offering surprisingly strong suction for a stick vacuum, making it an excellent contender for the best affordable vacuum for pet hair. Its lightweight design combined with the ability to convert into a handheld vacuum makes it incredibly versatile. This vacuum is specifically engineered with pet owners in mind, providing tools that effectively capture embedded pet hair from various surfaces.

See also  7 Best Vacuum Sealers For Food: Expert Picks For Freshness

Key Features That Stand Out

  • Powerful Suction: Delivers thorough deep carpet cleaning and robust pet hair pickup on all types of surfaces, from stairs to hard floors.
  • Ultra-Lightweight Versatility: Its extremely light build (around 9 lbs) makes it easy to maneuver, and it effortlessly converts into a handheld unit for high-up or furniture cleaning.
  • Specialized Pet Tools: Comes with dedicated attachments designed to capture stubborn, embedded pet hair, ensuring your home stays fur-free.
  • Floor-to-Ceiling Cleaning: The slim profile and handheld conversion allow it to reach tight spaces and elevated areas where pet hair often hides.
  • Corded Reliability: Provides consistent, fade-free power, meaning you’ll never run out of charge mid-clean.

Why We Recommend It

We recommend the Shark Rocket Pet Plus for its impressive suction and adaptability, particularly for a corded stick vacuum in the affordable range. It excels at tackling diverse pet hair challenges, from deep carpets to delicate upholstery, thanks to its specialized tools and convertible design. It’s a fantastic option for pet owners seeking powerful, targeted cleaning without the bulk of a traditional upright.

Best For

This vacuum is best for pet owners living in apartments or smaller homes who need powerful, versatile pet hair removal and appreciate the consistent suction of a corded model.

Pros and Cons

Pros:
  • Strong suction for a stick vacuum, excellent on pet hair
  • Extremely lightweight and easy to handle
  • Converts to a handheld for ultimate versatility
  • Includes effective specialized pet tools
  • Consistent power from corded design
Cons:
  • Smaller dust cup requires frequent emptying with heavy shedding
  • Corded operation means plugging and unplugging
  • Can be a bit top-heavy when used as a stick vacuum

Customer Reviews

Customer Review: “This Shark Rocket is a game-changer for my apartment! It’s super lightweight, making it easy to carry up and down stairs, and the suction power is incredible. My two cats shed constantly, and this vacuum picks up every strand of hair from my rugs and hardwood floors. Converting it to a handheld is a breeze for furniture and car cleaning. Highly recommend for pet owners on a budget!”

Customer Review: “I bought this for quick cleanups between professional cleanings, and it does a fantastic job with pet hair. The suction is really impressive for a stick vacuum. My only minor gripe is the small dust cup; I have to empty it quite often with two dogs. Also, being corded means I have to switch outlets sometimes, but for the price and performance, it’s a trade-off I’m willing to make.”

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

5. Bissell CleanView Swivel Upright Bagless Vacuum for Powerful Pet Hair Pickup with Tools

Bissell CleanView Swivel Upright Bagless Vacuum for Powerful Pet Hair Pickup with Tools

The Bissell CleanView Swivel Upright Bagless Vacuum is a fantastic choice for pet parents seeking powerful, comprehensive pet hair pickup without a premium price tag. Bissell is well-known for its dedication to pet-friendly cleaning, and this model, often recognized as one of the best affordable vacuum for pet hair, lives up to that reputation. Its standout features like Swivel Steering and the Triple Action Brush Roll make tackling even the most stubborn pet messes a breeze.

Key Features That Stand Out

  • Triple Action Brush Roll: Uniquely designed to loosen, lift, and remove embedded pet hair from various surfaces, including deep carpets.
  • Swivel Steering: Provides maximum maneuverability, allowing you to easily navigate around furniture and obstacles for a more thorough clean.
  • Powerful Suction: Delivers strong, consistent suction to pick up pet hair, dirt, and debris efficiently across different floor types.
  • Bagless Design: Features an easy-to-empty dirt tank, ensuring convenient and hygienic disposal of collected pet hair.
  • Supports BISSELL Pet Foundation: A portion of every purchase goes towards helping save homeless pets, adding a heartwarming bonus to your buy.

Why We Recommend It

We highly recommend the Bissell CleanView Swivel for its exceptional pet hair performance, especially on carpets where fur tends to embed. The combination of the Triple Action Brush Roll and swivel steering makes cleaning effective and surprisingly easy for an upright vacuum. Plus, supporting a cause that helps homeless pets is always a win in our book.

Best For

This vacuum is best for pet owners with heavy-shedding pets, particularly those with a mix of carpeted and hard floor areas, who desire powerful suction and easy maneuverability.

Pros and Cons

Pros:
  • Excellent at picking up embedded pet hair with Triple Action Brush Roll
  • Swivel steering makes maneuvering around furniture effortless
  • Strong suction power for thorough cleaning
  • Bagless design for easy, mess-free emptying
  • Supports a charitable cause (BISSELL Pet Foundation)
Cons:
  • Can be a bit heavier than stick or handheld vacuums
  • May not fit under very low furniture easily
  • Corded operation limits range compared to cordless models

Customer Reviews

Customer Review: “Vacuum is really nice and picks up very well. The pet remover tool works great as well on my cats tower and other furniture. I am happy with this product. It is not as loud as other vacuums. Easy to use and put together. Lightweight and swivel is nice along with the cord rewind. Long cord.”

Customer Review: “This vacuum cleaner is really good — the suction power is excellent. It picks up hair, pet fur, dust, and even crumbs very well. The only downside is that it’s a bit inconvenient to use under the bed or couch, and it’s slightly heavy. Overall, though, it works great!😍”

Complete Buying Guide for Best Affordable Vacuum For Pet Hair

Choosing the best affordable vacuum for pet hair can feel overwhelming with so many options available. To help you make an informed decision, here are the essential factors we considered when selecting our top picks, along with advice on budgeting and final thoughts.

Essential Factors We Consider

When evaluating vacuums for pet hair, especially within an affordable range, we focus on specific features that truly make a difference:

  • Suction Power: This is paramount for lifting embedded pet hair from carpets and picking it up efficiently from hard floors. We look for models with strong, consistent suction.
  • Brush Type: A good brushroll is crucial. For carpets, a motorized brush is best for agitating and lifting hair. For hard floors, softer bristles or a brushroll that can be turned off prevents scratching. Tangle-free brushrolls are a huge bonus for pet owners.
  • Filtration System: Pet dander can be an allergen, so a vacuum with a good filtration system, ideally a HEPA filter, is a major plus to trap allergens and fine dust.
  • Attachments for Pet Hair: Specialized tools like pet turbo brushes, upholstery tools, and crevice tools are indispensable for cleaning pet hair from furniture, stairs, and tight spots.
  • Weight and Maneuverability: A lighter vacuum with swivel steering makes cleaning less of a chore, especially if you have a multi-story home or lots of furniture to navigate around.
  • Corded vs. Cordless: Corded vacuums offer unlimited run time and often stronger, consistent suction. Cordless models provide unparalleled freedom and convenience for quick cleanups but have limited battery life.
  • Dustbin Capacity: Pet hair fills up dustbins quickly! A larger capacity means less frequent emptying, saving you time and hassle.
See also  5 Best On Board Air Compressors: Expert Top Picks

Budget Planning

An “affordable” vacuum typically falls within the $100-$250 range, though sometimes you can find great deals slightly above or below. When budgeting, consider what features are most critical for your home and pets. You might need to prioritize: do you need the absolute strongest suction, or is cordless convenience more important? Affordable vacuums often excel in one or two key areas but may have trade-offs in others (e.g., lightweight but less robust build, or powerful but corded). Always read reviews to ensure the specific model meets your core needs without unnecessary compromises.

Final Thoughts

Ultimately, the best affordable vacuum for pet hair is the one that fits your specific needs and lifestyle. Whether you need a featherlight stick vacuum for daily touch-ups or a powerful upright to deep clean after a heavy shedder, there’s a budget-friendly option out there for you. Don’t be afraid to compare features against your priorities. Investing in a good pet hair vacuum, even an affordable one, will significantly improve the cleanliness and comfort of your home, allowing you to enjoy your furry companions even more!

Frequently Asked Questions

Q: What features are most important in an affordable pet hair vacuum?

A: For an affordable pet hair vacuum, look for strong suction, a good brushroll (preferably with tangle-free features or easy cleaning), and versatile attachments like a pet turbo brush. HEPA filtration is a bonus for allergy sufferers, but may push the price slightly higher.

Q: Are bagless vacuums better for pet hair?

A: Bagless vacuums are often preferred for pet hair because they eliminate the recurring cost of bags and make it easy to see how much pet hair you’ve collected. However, emptying a bagless vacuum can sometimes release dust and dander back into the air, so consider emptying it outdoors if you have allergies.

Q: Can cordless vacuums handle heavy pet shedding?

A: Many affordable cordless vacuums can handle moderate pet shedding and are excellent for quick, daily cleanups. For heavy shedding or deep cleaning, a corded upright or stick vacuum might offer more consistent power and run time. If choosing cordless, look for models with good battery life (30+ minutes) and powerful suction settings.

Q: How often should I vacuum with pets?

A: With pets, especially heavy shedder, it’s generally recommended to vacuum at least 2-3 times a week. For homes with multiple pets or allergy sufferers, daily vacuuming of high-traffic areas might be necessary to keep pet hair and dander under control.

Q: What’s the best way to maintain a pet hair vacuum?

A: To keep your pet hair vacuum performing its best, regularly empty the dust cup, clean or replace filters as recommended by the manufacturer, and check the brushroll for tangled hair or debris. This helps maintain suction power and extends the life of your vacuum.

Managing pet hair doesn’t have to be an expensive endeavor. As you can see, there are many excellent, affordable vacuum for pet hair options that deliver impressive results. From lightweight uprights perfect for quick daily tidies to versatile stick vacuums that tackle hair on multiple surfaces, our top picks offer solutions for every pet-loving household. Remember to consider your specific needs—the type of flooring, the amount of shedding, and your cleaning preferences—to find your perfect match. With one of these budget-friendly vacuums, you can keep your home cleaner and enjoy more precious moments with your beloved furry companions. Click here to explore more affordable pet hair vacuums on Amazon and find the best one for your home today!

// Fetch real-time product data for all products when page loads
(function() {
const products = [‘B0BN5F6MJY’, ‘B09QYB17J2’, ‘B091SWWH59’, ‘B00NGVF4II’, ‘B07F6N3RT6’];
const affiliateTag = ‘arcweldingpro0d-20’;

async function fetchLiveProductData(asin) {
try {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘⏳ Fetching…’;

const amazonUrl = ‘https://www.amazon.com/dp/’ + asin;
const response = await fetch(‘https://api.allorigins.win/raw?url=’ + encodeURIComponent(amazonUrl));
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, ‘text/html’);

let price = null;
const priceWhole = doc.querySelector(‘.a-price-whole’);
const priceFraction = doc.querySelector(‘.a-price-fraction’);
if (priceWhole) {
price = ‘$’ + priceWhole.textContent.trim() + (priceFraction ? priceFraction.textContent.trim() : ”);
}

let rating = null;
const ratingEl = doc.querySelector(‘[data-hook=”average-star-rating”] .a-icon-alt’);
if (ratingEl) {
const match = ratingEl.textContent.match(/(\d+\.\d+)/);
if (match) rating = match[1];
}

let reviewCount = null;
const reviewEl = doc.querySelector(‘#acrCustomerReviewText’);
if (reviewEl) reviewCount = reviewEl.textContent.trim();

if (price) {
const priceEl = document.getElementById(‘price-‘ + asin);
if (priceEl) {
priceEl.innerHTML = price;
priceEl.style.animation = ‘pulse 0.5s’;
}
}

// if (rating) {
// const ratingEl = document.getElementById(‘rating-‘ + asin);
// if (ratingEl) {
// const stars = ‘⭐’.repeat(Math.floor(parseFloat(rating)));
// ratingEl.innerHTML = stars + ‘ ‘ + rating + ‘/5’;
// ratingEl.style.animation = ‘pulse 0.5s’;
// }
// }

if (reviewCount) {
const reviewsEl = document.getElementById(‘reviews-‘ + asin);
if (reviewsEl) {
reviewsEl.innerHTML = reviewCount;
reviewsEl.style.animation = ‘pulse 0.5s’;
}
}

if (updateTimeEl) {
const now = new Date();
const timeStr = now.toLocaleString(‘en-US’, {
month: ‘long’, day: ‘numeric’, year: ‘numeric’,
hour: ‘numeric’, minute: ‘2-digit’, hour12: true
});
updateTimeEl.innerHTML = ‘✓ Updated: ‘ + timeStr;
}
} catch (error) {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘✓ Cached data’;
}
}

const style = document.createElement(‘style’);
style.textContent = `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }`;
document.head.appendChild(style);

function loadAllProducts() {
products.forEach((asin, index) => {
setTimeout(() => fetchLiveProductData(asin), index * 2000);
});
}

if (document.readyState === ‘loading’) {
document.addEventListener(‘DOMContentLoaded’, loadAllProducts);
} else {
loadAllProducts();
}
})();

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top