The JSON-LD-first approach is a good call. Class names like Nx9bqj break every few weeks, while structured data tends to hold up much longer.
I also like that the alert only fires when the price is below target and has just dropped. That avoids getting the same email every run, and plenty of tutorials miss it.
One idea for the "lowest price ever" extension: since you already store every check in SQLite, a simple SELECT MIN(price) per URL would cover it. You could also alert only when the new price beats the previous all-time low, so you don't get notified for small dips.
Thanks for the honest notes on blocking and the terms of use too. Have you noticed Flipkart behaving differently when you check more often than every few hours?
You're right about JSON-LD. Hashed class names like that change without warning, whereas the structured data is there for search engines, so the site has a reason to keep it stable.
The "lowest price ever" idea fits the SQLite setup well. A SELECT MIN(price) ... WHERE url = ? would do it, and I like your suggestion of alerting only when the new price beats the previous all-time low. Pairing that with a small minimum-drop threshold (say 2-3%) would also filter out the noise from tiny fluctuations.
On check frequency, I haven't tested this systematically, but in general the more often you hit the site from the same IP, the more likely you are to see captchas, empty responses or 403s. For a personal tracker, every few hours with a bit of random jitter is a safer cadence. Prices on most products don't change that fast anyway, so checking more often rarely gets you more useful data. If you try tighter intervals, I'd be curious what you see.
Mayur Upadhyay delivers tech-driven solutions in Web Development, e-commerce development, and mobile app development, helping businesses to grow worldwide.
Structured data has held up better for me than class names, so I'd rather build on that and keep CSS selectors as a fallback.
Your SELECT MIN(price) idea fits well, since the history is already in SQLite. Alerting only when the new price beats the previous all-time low is a good way to cut noise from small dips. I may add a minimum-drop threshold on top of it, say at least 3-5% below the old low.
On check frequency, I'd keep it to every few hours with a bit of random jitter. Prices on most listings don't change that often, so polling faster rarely gains anything and makes you easier to spot and rate-limit. If you see CAPTCHAs, empty responses, or sudden HTTP errors, back off instead of retrying harder. Have you tried a tighter interval on your end?
Yes, JSON-LD has been much more reliable for me. I've had the class-name selector break a couple of times, but the structured data kept working. I still keep the CSS fallback in case a page doesn't include it.
The "lowest price ever" idea is a good one. Alerting only when the new price beats the previous all-time low is smarter than my version, because it filters out the small dips. I'll add it to the extensions list.
On your question: Yes, I noticed a difference. Checking every few hours worked fine, but when I tested more often, especially without delays between requests, I started getting 429 errors and sometimes a captcha page. That's why the script uses random delays and a low check frequency. Your mileage may vary depending on your IP and how many products you track.
Have you tried building something similar? Would love to hear what you add!
Preferring JSON-LD over CSS class names is a smart call, since those random class names like Nx9bqj break every few weeks.
The below_target and dropped check is also a good detail. Without it, you'd get an email on every run while the price stays low.
One idea for an extension: store a "lowest price ever" column in SQLite, so the alert can say "this is the cheapest it's been in 30 days" and not just "below your target." That makes it easier to decide whether to buy now or wait.
Thanks for sharing the full script. Is the 5-12 second delay enough to avoid captchas when tracking 10+ products, or have you had to stretch it?
Yes, a "lowest price in 30 days" column is a great idea. It's one extra query, SELECT MIN(price) ... WHERE checked_at > date('now', '-30 days'), and it makes the alert much more useful than just "below target."
For the delay: 5-12 seconds worked fine for me with a handful of products and a few checks per day. With 10+ products I'd stretch it to 10-20 seconds and shuffle the order each run. Also keep the schedule at every 6 hours or so, because request frequency matters more than the delay between products. If you start seeing 429s or captcha pages, back off before retrying.
If you try it with more products, let me know how it goes! 🙂
Mayur Upadhyay delivers tech-driven solutions in Web Development, e-commerce development, and mobile app development, helping businesses to grow worldwide.
Using JSON-LD first and class names only as a fallback is the right call, since those random class names like Nx9bqj break all the time.
One small edge case in the alert logic: below_target and dropped needs a previous price, so if you add a product that's already under your target, the first run saves the price and sends nothing. You could handle it with something like (previous is None or price < previous). Also, with price <= target plus price < previous, you'll get an alert on every further small drop while the price is below the target. That's probably fine, but you may want a "lowest price so far" check to cut noise.
Storing a history of prices also makes the "lowest price ever" idea easy to add: one SELECT MIN(price) query. Thanks for the GitHub Actions note about SQLite not persisting too. A lot of tutorials skip that.
Thanks for the careful read, and you're right on both points.
The first-run case is a real gap. If a product is already under target when you add it, previous is None, so dropped is False and nothing is sent. previous is None or price < previous fixes that, and I'll update the post.
On the noise: yes, price <= target plus price < previous will alert on every further small drop while the price stays below target. For a hobby tracker I thought that was acceptable, but a "lowest so far" check is cleaner. Here's roughly how I'd do it:
lowest=lowest_price(conn,p["url"])# check BEFORE saving today's pricesave_price(conn,p["url"],titleorp["name"],price)below_target=price<=p["target_price"]new_low=lowestisNoneorprice<lowestifbelow_targetandnew_low:send_email(...)
with a small helper:
deflowest_price(conn,url):row=conn.execute("SELECT MIN(price) FROM prices WHERE url = ?",(url,)).fetchone()returnrow[0]
Order matters here: if you save first, the MIN includes the current price and new_low never fires. A first-time product under target also alerts, since lowest is None.
Glad the GitHub Actions note helped. Thanks for the suggestions!
Good call keeping the scope small and being upfront about Flipkart blocking bots and changing its HTML. Most scraper tutorials skip that part, and it's what readers actually hit after a week.
Storing every price in SQLite instead of only comparing against the last one is the best design choice here, because it turns a simple alert script into something you can build on, like a price history chart or a "lowest price ever" alert, both of which you mention.
One small thing I'd add: when price is None, the script prints a warning and moves on. For a tracker that runs every 6 hours, I'd also log those misses to the DB. A product that suddenly returns None three runs in a row usually means a selector change or an out-of-stock page, and you'd want to know that rather than assume the price just didn't change.
Out of curiosity, how did you handle out-of-stock products? Does the JSON-LD still return a price, or does it come back empty?
Thanks, I'm glad the "this will break eventually" part was useful. That's the part people hit after a week.
You're right about the misses. Right now a None price only prints a warning, so a selector change and a plain "price didn't change" look the same in the history. A small checks table (url, status, checked_at) or a status column on prices would fix that. Then you could alert after 3 failed runs in a row, which at a 6-hour interval means about 18 hours of silence. I'll add this to the post as an update.
On out-of-stock, I haven't tested it properly, so I don't want to give you a confident answer. The script reads offers.price from the JSON-LD, and I can't say whether Flipkart drops that field, keeps the last price, or serves a different page for unavailable items. It probably varies by product and seller. The JSON-LD offers block usually has an availability field, so reading that next to the price would let the tracker tell "out of stock" apart from "selector broke". Right now both come back as None.
If you've seen what an out-of-stock page returns, I'd like to know. I can fold it into the post and credit you.
Free n8n workflows and AI agent skills (SKILL.md for Claude Code) for public-data scraping: Google Maps leads, Amazon prices, Zillow, Indeed jobs. All on scraperfinder.com (MIT), demos on YouTube.
Work
Maintainer of the free Scraper Finder n8n workflows and agent skills (MIT)
Thanks, glad it clicked with a fellow scraper lover! 😄 You're right. The below_target and dropped check is what turns the script into an event detector, since it only fires when something changes. That also means a missed run is costly: if the price dips and recovers between two checks, you never see it.
A few cheap ways to reduce that risk:
Check more often, with jitter. Every 2-3 hours instead of 6 is still gentle if you only track a few products.
Log failed runs. Right now a block or captcha just prints and moves on. Saving a "check failed" row, or sending yourself a "no price found" alert, tells you when you were blind.
Add a "lowest price ever" alert. It uses the history in SQLite, so it catches a dip you were offline for if a later run still sees the low price.
Are you running yours on cron, or somewhere always-on? 🙂
We're a place where coders share, stay up-to-date and grow their careers.
The JSON-LD-first approach is a good call. Class names like Nx9bqj break every few weeks, while structured data tends to hold up much longer.
I also like that the alert only fires when the price is below target and has just dropped. That avoids getting the same email every run, and plenty of tutorials miss it.
One idea for the "lowest price ever" extension: since you already store every check in SQLite, a simple
SELECT MIN(price)per URL would cover it. You could also alert only when the new price beats the previous all-time low, so you don't get notified for small dips.Thanks for the honest notes on blocking and the terms of use too. Have you noticed Flipkart behaving differently when you check more often than every few hours?
You're right about JSON-LD. Hashed class names like that change without warning, whereas the structured data is there for search engines, so the site has a reason to keep it stable.
The "lowest price ever" idea fits the SQLite setup well. A
SELECT MIN(price) ... WHERE url = ?would do it, and I like your suggestion of alerting only when the new price beats the previous all-time low. Pairing that with a small minimum-drop threshold (say 2-3%) would also filter out the noise from tiny fluctuations.On check frequency, I haven't tested this systematically, but in general the more often you hit the site from the same IP, the more likely you are to see captchas, empty responses or 403s. For a personal tracker, every few hours with a bit of random jitter is a safer cadence. Prices on most products don't change that fast anyway, so checking more often rarely gets you more useful data. If you try tighter intervals, I'd be curious what you see.
Structured data has held up better for me than class names, so I'd rather build on that and keep CSS selectors as a fallback.
Your
SELECT MIN(price)idea fits well, since the history is already in SQLite. Alerting only when the new price beats the previous all-time low is a good way to cut noise from small dips. I may add a minimum-drop threshold on top of it, say at least 3-5% below the old low.On check frequency, I'd keep it to every few hours with a bit of random jitter. Prices on most listings don't change that often, so polling faster rarely gains anything and makes you easier to spot and rate-limit. If you see CAPTCHAs, empty responses, or sudden HTTP errors, back off instead of retrying harder. Have you tried a tighter interval on your end?
Thanks, glad it was useful! 🙌
Yes, JSON-LD has been much more reliable for me. I've had the class-name selector break a couple of times, but the structured data kept working. I still keep the CSS fallback in case a page doesn't include it.
The "lowest price ever" idea is a good one. Alerting only when the new price beats the previous all-time low is smarter than my version, because it filters out the small dips. I'll add it to the extensions list.
On your question: Yes, I noticed a difference. Checking every few hours worked fine, but when I tested more often, especially without delays between requests, I started getting 429 errors and sometimes a captcha page. That's why the script uses random delays and a low check frequency. Your mileage may vary depending on your IP and how many products you track.
Have you tried building something similar? Would love to hear what you add!
Preferring JSON-LD over CSS class names is a smart call, since those random class names like
Nx9bqjbreak every few weeks.The
below_target and droppedcheck is also a good detail. Without it, you'd get an email on every run while the price stays low.One idea for an extension: store a "lowest price ever" column in SQLite, so the alert can say "this is the cheapest it's been in 30 days" and not just "below your target." That makes it easier to decide whether to buy now or wait.
Thanks for sharing the full script. Is the 5-12 second delay enough to avoid captchas when tracking 10+ products, or have you had to stretch it?
Yes, a "lowest price in 30 days" column is a great idea. It's one extra query,
SELECT MIN(price) ... WHERE checked_at > date('now', '-30 days'), and it makes the alert much more useful than just "below target."For the delay: 5-12 seconds worked fine for me with a handful of products and a few checks per day. With 10+ products I'd stretch it to 10-20 seconds and shuffle the order each run. Also keep the schedule at every 6 hours or so, because request frequency matters more than the delay between products. If you start seeing 429s or captcha pages, back off before retrying.
If you try it with more products, let me know how it goes! 🙂
Using JSON-LD first and class names only as a fallback is the right call, since those random class names like
Nx9bqjbreak all the time.One small edge case in the alert logic:
below_target and droppedneeds a previous price, so if you add a product that's already under your target, the first run saves the price and sends nothing. You could handle it with something like(previous is None or price < previous). Also, withprice <= targetplusprice < previous, you'll get an alert on every further small drop while the price is below the target. That's probably fine, but you may want a "lowest price so far" check to cut noise.Storing a history of prices also makes the "lowest price ever" idea easy to add: one
SELECT MIN(price)query. Thanks for the GitHub Actions note about SQLite not persisting too. A lot of tutorials skip that.Thanks for the careful read, and you're right on both points.
The first-run case is a real gap. If a product is already under target when you add it,
previousisNone, sodroppedisFalseand nothing is sent.previous is None or price < previousfixes that, and I'll update the post.On the noise: yes,
price <= targetplusprice < previouswill alert on every further small drop while the price stays below target. For a hobby tracker I thought that was acceptable, but a "lowest so far" check is cleaner. Here's roughly how I'd do it:with a small helper:
Order matters here: if you save first, the
MINincludes the current price andnew_lownever fires. A first-time product under target also alerts, sincelowestisNone.Glad the GitHub Actions note helped. Thanks for the suggestions!
Good call keeping the scope small and being upfront about Flipkart blocking bots and changing its HTML. Most scraper tutorials skip that part, and it's what readers actually hit after a week.
Storing every price in SQLite instead of only comparing against the last one is the best design choice here, because it turns a simple alert script into something you can build on, like a price history chart or a "lowest price ever" alert, both of which you mention.
One small thing I'd add: when
price is None, the script prints a warning and moves on. For a tracker that runs every 6 hours, I'd also log those misses to the DB. A product that suddenly returnsNonethree runs in a row usually means a selector change or an out-of-stock page, and you'd want to know that rather than assume the price just didn't change.Out of curiosity, how did you handle out-of-stock products? Does the JSON-LD still return a price, or does it come back empty?
Thanks, I'm glad the "this will break eventually" part was useful. That's the part people hit after a week.
You're right about the misses. Right now a
Noneprice only prints a warning, so a selector change and a plain "price didn't change" look the same in the history. A smallcheckstable (url, status, checked_at) or astatuscolumn onpriceswould fix that. Then you could alert after 3 failed runs in a row, which at a 6-hour interval means about 18 hours of silence. I'll add this to the post as an update.On out-of-stock, I haven't tested it properly, so I don't want to give you a confident answer. The script reads
offers.pricefrom the JSON-LD, and I can't say whether Flipkart drops that field, keeps the last price, or serves a different page for unavailable items. It probably varies by product and seller. The JSON-LDoffersblock usually has anavailabilityfield, so reading that next to the price would let the tracker tell "out of stock" apart from "selector broke". Right now both come back asNone.If you've seen what an out-of-stock page returns, I'd like to know. I can fold it into the post and credit you.
As a scraper lover :) The just-dropped rule turns a price alert into an event detector, so a missed run can cost you the deal.
Thanks, glad it clicked with a fellow scraper lover! 😄 You're right. The
below_target and droppedcheck is what turns the script into an event detector, since it only fires when something changes. That also means a missed run is costly: if the price dips and recovers between two checks, you never see it.A few cheap ways to reduce that risk:
Are you running yours on cron, or somewhere always-on? 🙂