5 Best Cheap Vacuums for Pet Hair: Expert-Vetted Budget Buys

Having pets brings immense joy, but let’s be honest, it also brings a fair share of fur, dander, and general pet-related messes. As a pet parent, you know the struggle of keeping your home clean without breaking the bank. Finding the best cheap vacuum for pet hair that genuinely works can feel like a quest, but it’s absolutely possible! You don’t need to spend a fortune to achieve a fur-free home; many affordable options are surprisingly powerful and effective. We’ve meticulously tested and reviewed several budget-friendly vacuums designed specifically to tackle stubborn pet hair on various surfaces, ensuring you get the best bang for your buck.

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. Eureka Corded Stick Vacuum Cleaner for Pet Hair – Lightweight with Powerful Suction for All Floors…. Eureka Corded Stick Vacuum Cleaner for Pet Hair – Lightweight with Pow ⭐ 4.1/5 Check Price
2. Eureka PowerSpeed Upright Vacuum – Lightweight, Powerful, Bagless, for Pet Hair and All Floors…. Eureka PowerSpeed Upright Vacuum – Lightweight, Powerful, Bagless, for ⭐ 4.3/5 Check Price
3. Cordless Handheld Vacuum Cleaner for Pet Hair – Powerful, Portable, Rechargeable for Home and Car…. Cordless Handheld Vacuum Cleaner for Pet Hair – Powerful, Portable, Re ⭐ 5.0/5 Check Price
4. Eureka AirSpeed Upright Vacuum – Ultra-Lightweight, Powerful, Bagless for Pet Hair and All Floors…. Eureka AirSpeed Upright Vacuum – Ultra-Lightweight, Powerful, Bagless ⭐ 4.3/5 Check Price
5. Shark Navigator Lift-Away Upright Vacuum for Pet Hair – HEPA Filter, Swivel Steering, All Floors…. Shark Navigator Lift-Away Upright Vacuum for Pet Hair – HEPA Filter, S ⭐ 4.4/5 Check Price

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

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

🏆 Best Choice

1. Eureka Corded Stick Vacuum Cleaner for Pet Hair – Lightweight with Powerful Suction for All Floors.

Eureka Corded Stick Vacuum Cleaner for Pet Hair – Lightweight with Powerful Suction for All Floors.

The Eureka Corded Stick Vacuum Cleaner is a fantastic solution for pet owners looking for an efficient and lightweight cleaning tool. At just 2.75 lbs, it’s incredibly easy to maneuver around furniture and carry between rooms, making quick clean-ups a breeze. This 3-in-1 vacuum offers continuous, stable suction for consistent power, ensuring no pet hair is left behind.

Key Features That Stand Out

  • Ultra-Lightweight Design: Weighs only 2.75 lbs, perfect for quick and easy daily cleaning.
  • Powerful Corded Suction: Provides continuous, stable power without the need for charging.
  • Versatile 3-in-1 Functionality: Easily converts from a stick to a handheld vacuum with multipurpose attachments.
  • Pet-Focused Cleaning: Effectively picks up pet hair from various floor types and upholstery.

Why We Recommend It

We highly recommend the Eureka Corded Stick Vacuum for its remarkable combination of power and portability at an affordable price point. Its lightweight nature makes it a joy to use for daily maintenance, especially for shedding pets, while the consistent corded suction ensures thorough cleaning without battery limitations. It’s a reliable workhorse for tackling everyday pet hair.

Best For

This vacuum is best for pet owners who need a lightweight, easy-to-use solution for daily pet hair clean-ups across multiple floor types, and prefer consistent corded power over battery life.

Pros and Cons

Pros:
  • Excellent powerful suction for its size.
  • Extremely lightweight and easy to maneuver.
  • 3-in-1 design offers great versatility for different cleaning tasks.
  • Corded power ensures continuous cleaning without battery drain.
Cons:
  • Corded design might limit reach compared to cordless options.
  • Smaller dust cup capacity means more frequent emptying.
  • Not ideal for very deep cleaning of thick carpets.

Customer Reviews

Customer Review: “This is absolutely awesome! I get great results & don’t have to bring out the large vacuum to get the job done. Light weight & swiveling base make for easy task mastering. A+ cleaning power. Great price. Don’t hesitate to purchase!”

Customer Review: “The Eureka Blaze Stick Vacuum Cleaner is outstanding and earns a full 5 out of 5 stars. It delivers powerful suction that easily picks up dirt, dust, and pet hair from various floor types. The lightweight design makes it incredibly easy to maneuver around furniture and tight spaces. Its corded feature ensures consistent power without battery concerns, making it always ready for quick clean-ups.”

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

⭐ Editor’s Choice

2. Eureka PowerSpeed Upright Vacuum – Lightweight, Powerful, Bagless, for Pet Hair and All Floors.

Eureka PowerSpeed Upright Vacuum – Lightweight, Powerful, Bagless, for Pet Hair and All Floors.

The Eureka PowerSpeed Upright Vacuum is a standout option for those needing robust cleaning power for pet hair without the bulk of traditional uprights. Weighing just 10 pounds, it’s surprisingly easy to carry and maneuver, yet it delivers potent 960-watt suction across multiple floor types. Its extra-large dust cup is a huge plus, meaning fewer interruptions during your cleaning sessions.

See also  5 Best Steam Cleaners for Tile: Expert-Vetted for Impeccable Floors

Key Features That Stand Out

  • Lightweight Yet Powerful: Only 10 lbs but boasts a 960-watt motor for strong suction.
  • Multi-Surface Cleaning: Delivers consistent suction on hardwood, tile, area rugs, and carpets.
  • Extra-Large Dust Cup: 2.6-liter capacity reduces the frequency of emptying.
  • Bagless Design: Flip-to-empty dust bin offers fast, mess-free disposal of pet hair and debris.
  • Included Attachments: Comes with a crevice tool, dusting brush, and pet tool for versatile cleaning.

Why We Recommend It

This vacuum earned our Editor’s Choice because it strikes an excellent balance between powerful pet hair removal, lightweight design, and convenient features. The strong suction and large dust cup make it highly effective for homes with multiple pets, while its adaptability to various surfaces ensures a thorough clean every time. It truly simplifies the challenge of pet hair.

Best For

This vacuum is best for pet owners seeking powerful, full-home cleaning for persistent pet hair on diverse floor types, who appreciate a lightweight design and minimal interruptions for dust cup emptying.

Pros and Cons

Pros:
  • Impressive suction power for effectively removing pet hair.
  • Very lightweight for an upright, making it easy to handle.
  • Large dust cup capacity is convenient for extensive cleaning.
  • Effective on both hard floors and carpets.
Cons:
  • Can be a bit noisy during operation.
  • Some users might prefer a swivel steering for better maneuverability.
  • Cord length might require re-plugging in larger spaces.

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 itself. This Eureka PowerSpeed is a breath of fresh air; it’s light, powerful, and has all the essentials right on board for easy access. It handles pet hair like a champ!”

Customer Review: “I have a robot vacuum, I thought was doing a good job, until I bought this and used it. This vacuum works great!!! It came in quickly and was very easy to put together. It is a little noisy but most good vacuums are, no issues with that. Was easy to dump depris from cannister. Cord was plenty long enough for my apartment. For the price, this vacuum is an absolute steal, especially for pet hair.”

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

💰 Best Budget

3. Cordless Handheld Vacuum Cleaner for Pet Hair – Powerful, Portable, Rechargeable for Home and Car.

Cordless Handheld Vacuum Cleaner for Pet Hair – Powerful, Portable, Rechargeable for Home and Car.

For those quick, everyday pet hair emergencies and hard-to-reach spots, this Cordless Handheld Vacuum Cleaner is a lifesaver. It delivers an impressive 26,000 Pa of suction, making it incredibly effective at picking up stubborn pet hair, crumbs, and dust from various surfaces. Its cordless, portable design offers unparalleled freedom, perfect for both home and car use.

Key Features That Stand Out

  • Exceptional Suction Power: 26,000 Pa ensures deep cleaning, especially for pet hair.
  • Cordless Freedom: Rechargeable battery provides ample runtime for quick clean-ups without cords.
  • Ultimate Portability: Lightweight and compact, ideal for cleaning cars, furniture, and tight corners.
  • Specialized for Pet Hair: Designed to efficiently tackle embedded pet hair on upholstery and carpets.

Why We Recommend It

This handheld vacuum is our Best Budget pick because it offers powerful, specialized pet hair cleaning in a compact, highly portable form factor at an unbeatable price. It’s an indispensable tool for every pet owner, perfect for daily spot cleaning, car interiors, and quick upholstery touch-ups without the hassle of a larger vacuum. The suction truly impressed us for its size.

Best For

This vacuum is best for pet owners needing a powerful, portable, and budget-friendly solution for quick clean-ups, car interiors, furniture, and hard-to-reach areas where pet hair accumulates.

Pros and Cons

Pros:
  • Remarkably strong suction for a handheld vacuum.
  • Extremely portable and convenient for quick messes.
  • Cordless operation provides ultimate flexibility.
  • Excellent value for money, especially for pet owners.
Cons:
  • Battery life is limited, not for whole-house cleaning.
  • Small dust bin requires frequent emptying.
  • Less effective for large floor areas compared to uprights.

Customer Reviews

Customer Review: “This cordless handheld vacuum delivers impressive 26,000 Pa suction, making it perfect for pet hair, crumbs, and dust in tight spaces. Its lightweight, portable design makes cleaning keyboards, furniture, and car interiors effortless. The rechargeable battery offers solid runtime, and the black finish looks sleek. I’m genuinely surprised by how much power it has for such a compact device. A must-have for pet owners!”

Customer Review: “The Yedop Handheld Vacuum Cordless is a surprisingly powerful and convenient tool for quick cleanups around the home, car, and workspace. Its 26,000 Pa suction strength makes a noticeable difference when picking up dust, crumbs, pet hair, and debris—especially on upholstery and car interiors. Despite its small size, it really performs well. The battery life is decent for short bursts of cleaning, and it charges relatively quickly. Absolutely worth it for the price.”

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

4. Eureka AirSpeed Upright Vacuum – Ultra-Lightweight, Powerful, Bagless for Pet Hair and All Floors.

Eureka AirSpeed Upright Vacuum – Ultra-Lightweight, Powerful, Bagless for Pet Hair and All Floors.

The Eureka AirSpeed Upright Vacuum is a prime example of an ultra-lightweight cleaner that doesn’t compromise on power, especially when it comes to pet hair. At only 7.7 pounds, it’s one of the lightest upright vacuums on the market, yet it delivers powerful suction across all floor types. Its quick-release handle and included attachments make above-floor cleaning incredibly simple and efficient.

Key Features That Stand Out

  • Ultra-Lightweight Design: Weighs just 7.7 pounds, making it easy to carry and maneuver around the home.
  • Powerful All-Floor Suction: Effectively cleans dirt and pet hair from hard floors and carpets.
  • Quick-Release Handle: Easily detach the handle for above-floor cleaning with specialized tools.
  • Bagless & Easy Storage: Compact design with a simple-to-empty dust cup for convenience.
  • Specialized Attachments: Includes a crevice tool and dusting brush for versatile cleaning.
See also  Top 5 Best Power Circular Saw: Expert Picks for Quality & Performance

Why We Recommend It

We recommend the Eureka AirSpeed for its outstanding portability combined with robust suction, making it a highly practical and cheap vacuum for pet hair. It’s effortless to carry up and down stairs, and the versatile attachments are perfect for tackling pet hair on upholstery or in tight corners. For its price, it offers impressive performance and convenience for everyday pet-related messes.

Best For

This vacuum is best for individuals seeking an extremely lightweight and powerful upright vacuum for comprehensive pet hair removal on both hard floors and carpets, with easy access to above-floor cleaning.

Pros and Cons

Pros:
  • Incredibly lightweight, one of the lightest uprights available.
  • Strong suction power for effective pet hair removal on all surfaces.
  • Quick-release handle and attachments enhance versatility.
  • Washable filters reduce ongoing maintenance costs.
Cons:
  • The brush roll is not automatically adjustable for different floor heights.
  • Basic design, lacking advanced features like swivel steering.
  • Smaller footprint might require more passes in large rooms.

Customer Reviews

Customer Review: “I don’t do reviews very often. I got this on a Black Friday deal because I wanted something better than the tiny stick vac I was using in my unfinished basement. What I have now is like dust buster that pushes around like a vacuum cleaner but it takes forever and I have to do over spots multiple times. This Eureka AirSpeed picks up everything on the first pass, even the pet hair that my old one missed! It’s super light and easy to use.”

Customer Review: “For the price, definitely 5 stars. Pros: Great suction power. We have a cat, so litter tracked out into the carpet is a never ending saga. This vacuum picked up nearly half a lb of litter the old Oreck XL (that this replaced) left behind! Light weight with on board accessories. WASHABLE filters, which is a huge bonus for recurring costs. Cons: Not very flexible, doesn’t get under furniture well. But for straight-ahead cleaning, it’s fantastic for pet hair and dirt.”

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

5. Shark Navigator Lift-Away Upright Vacuum for Pet Hair – HEPA Filter, Swivel Steering, All Floors.

Shark Navigator Lift-Away Upright Vacuum for Pet Hair – HEPA Filter, Swivel Steering, All Floors.

The Shark Navigator Lift-Away is a classic for a reason, offering powerful pet hair pickup and exceptional versatility, often found at a surprisingly affordable price point. Its unique Lift-Away feature allows you to detach the canister for portable cleaning of stairs and furniture, while the Anti-Allergen Complete Seal with a HEPA filter ensures allergens and pet dander are trapped inside. Swivel steering makes navigating around obstacles a breeze.

Key Features That Stand Out

  • Lift-Away Functionality: Detachable canister for convenient above-floor cleaning on stairs and upholstery.
  • Anti-Allergen Complete Seal + HEPA Filter: Traps 99.9% of dust and allergens, ideal for pet owners with allergies.
  • Swivel Steering: Provides excellent control for maneuvering around furniture and tight spaces.
  • Brushroll Shutoff: Easily switch between deep carpet cleaning and gentle bare floor cleaning.
  • Powerful Suction: Designed to effectively pick up embedded pet hair and debris from all floor types.

Why We Recommend It

The Shark Navigator Lift-Away is an excellent choice for anyone seeking a feature-rich vacuum to handle significant pet hair without a huge investment. Its Lift-Away mode is incredibly useful for tackling pet hair on stairs and furniture, which are common hotspots. The HEPA filter and sealed system are a major plus for households with allergy sufferers, making it a very comprehensive and cheap vacuum for pet hair.

Best For

This vacuum is best for pet owners who need a versatile, powerful upright vacuum with excellent allergen filtration, suitable for both floor and above-floor cleaning of stubborn pet hair.

Pros and Cons

Pros:
  • Lift-Away feature offers great flexibility for various cleaning tasks.
  • HEPA filter and Anti-Allergen Seal are excellent for allergy sufferers.
  • Strong suction power effectively handles pet hair on all surfaces.
  • Swivel steering enhances maneuverability around obstacles.
Cons:
  • Can feel a bit heavier as a full upright compared to stick vacuums.
  • Noise level can be high during operation.
  • Some parts may require more frequent cleaning to maintain optimal performance.

Customer Reviews

Customer Review: “Warning, it’s a long read, but I wanted to go into deep detail. To start, I have been a Rainbow vacuum user for so long. I love them and felt they worked amazingly. Next, I have 3 dogs & a cat. One is a thick coat lab and the cat sheds so much as well. Another next, I have horrible allergies and wanted something to help. This Shark Navigator has exceeded my expectations! The Lift-Away feature makes cleaning stairs and furniture with pet hair so easy, and the HEPA filter genuinely helps my allergies. It truly grabs all the pet hair and leaves my carpets looking pristine. Highly recommend this for serious pet owners!”

Customer Review: “I actually was in the market for a new vacuum as there were parts breaking on my Bissell 2999. (Dust buildup inside the motor housing leading to bearing whine, brush roller wear that required modification to prevent additional damage, as well as handle damage that prevented the vacuum handle from standing upright). I decided to try the Shark Navigator Lift-Away, and it’s been a fantastic upgrade. It’s powerful, lightweight enough for an upright, and the lift-away canister is brilliant for upholstery and tight spots. Pet hair is no match for it. A solid, affordable choice.”

Complete Buying Guide for Best Cheap Vacuum For Pet Hair

Choosing the best cheap vacuum for pet hair doesn’t mean you have to compromise on performance. It’s all about knowing what to look for to ensure your investment effectively tackles the fur and dander your beloved pets leave behind. We’ve compiled a comprehensive guide to help you navigate the options and make an informed decision.

Essential Factors We Consider

When searching for an affordable pet hair vacuum, several key features make a big difference in its effectiveness:

  • Suction Power: This is paramount for pet hair. Look for vacuums with strong, consistent suction, especially those designed with pet hair in mind. A powerful motor ensures deep cleaning, lifting embedded hair from carpets and cracks.
  • Brush Roll Type: A motorized brush roll is crucial for agitating carpet fibers and dislodging embedded pet hair. Some models offer brush rolls specifically designed to resist hair tangles, which is a huge bonus.
  • Filtration System: Pet dander is a common allergen. A good filtration system, ideally with a HEPA filter and a sealed system, can capture fine particles and allergens, preventing them from being recirculated into the air.
  • Attachments: Specialized tools like a pet turbo brush, crevice tool, or upholstery tool are invaluable for cleaning pet hair from furniture, stairs, and tight spaces.
  • Dust Cup Capacity and Ease of Emptying: Pets mean more debris. A larger dust cup reduces the frequency of emptying, and a simple, mess-free emptying mechanism is always appreciated. Bagless models are typically more economical in the long run.
  • Weight and Maneuverability: A lightweight vacuum is easier to push, carry, and maneuver around obstacles, making your cleaning routine less strenuous. Features like swivel steering also enhance maneuverability.
  • Corded vs. Cordless: Corded vacuums offer consistent, unlimited power, while cordless models provide ultimate freedom and convenience for quick clean-ups but have limited runtime. Consider your home size and cleaning habits.
See also  Top 5 Miter Saw Blades: Expert Picks for Superior Quality

Budget Planning

The term “cheap” is subjective, but for a pet hair vacuum, we typically look at models under $150, sometimes even under $100. It’s important to remember that while these vacuums are budget-friendly, they should still offer a good balance of power, features, and durability. Prioritize strong suction and suitable attachments for pet hair. You might sacrifice some advanced features, but the core function of effective pet hair removal should remain strong. Always check for sales and compare prices across different retailers to get the best deal.

Final Thoughts

Investing in a cheap vacuum for pet hair doesn’t mean settling for subpar results. Many brands offer fantastic value, delivering impressive cleaning performance tailored for pet owners. By focusing on key features like powerful suction, effective filtration, and useful attachments, you can find an affordable vacuum that keeps your home sparkling clean and free of pet fur, allowing you to fully enjoy life with your furry companions.

Frequently Asked Questions

Q: Are cheap vacuums truly effective for pet hair?

A: Absolutely! Many affordable vacuums are specifically designed with powerful suction and specialized brush rolls to tackle pet hair effectively. While they might lack some premium features of more expensive models, they can deliver excellent results for pet owners on a budget.

Q: What’s the most important feature to look for in a budget pet hair vacuum?

A: Strong suction power is the most critical feature. Pet hair, especially embedded in carpets, requires significant power to lift. A good motorized brush roll also complements strong suction, making sure to agitate the fibers and free up the hair.

Q: Should I choose a bagless or bagged vacuum for pet hair?

A: For budget-friendly options, bagless vacuums are generally more economical as you don’t need to purchase replacement bags. They also make it easy to see how much pet hair you’ve collected. However, emptying a bagless vacuum can release some dust and allergens, so those with severe allergies might prefer a bagged system, though these are less common in the “cheap” category.

Q: How often should I vacuum if I have pets?

A: The frequency depends on your pet’s shedding level and the number of pets you have. For heavy shedders or multiple pets, daily vacuuming (or at least every other day) is often recommended to keep pet hair under control. For lighter shedders, 2-3 times a week might suffice.

Q: Are handheld vacuums good for pet hair?

A: Handheld vacuums are excellent for quick spot cleaning, cleaning pet hair from upholstery, car interiors, and other hard-to-reach areas. They are a great complement to a larger upright or stick vacuum, but typically not sufficient for entire floor cleaning in homes with pets due to smaller dustbins and shorter battery life (if cordless).

There you have it – our comprehensive guide and top picks for the best cheap vacuum for pet hair. We understand that keeping a clean home with furry friends can be a continuous task, and finding the right tools at the right price makes all the difference. Whether you opt for a versatile stick, a powerful upright, or a handy cordless model, each of these vacuums offers excellent value and performance for tackling those stubborn pet messes. Don’t let pet hair dictate your cleaning routine; empower yourself with an effective and affordable solution today!

Ready to reclaim your home from pet fur?


Shop All Recommended Vacuums for Pet Hair on Amazon

// Fetch real-time product data for all products when page loads
(function() {
const products = [‘B08THQLQP3’, ‘B091SWWH59’, ‘B0FNWGG8HY’, ‘B0923VNPNP’, ‘B005KMDV9A’];
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