mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-24 15:48:11 +02:00
feat: Implement scheduler service for automated product price and stock tracking with AI extraction and robust comparison logic.
This commit is contained in:
1 parent
844c75f190
commit
a5578e017d
1 file changed
+31
-5
@@ -298,19 +298,45 @@ async def process_item_check(item_id: int):
|
|||||||
if not titles_match:
|
if not titles_match:
|
||||||
# If titles don't match, check if it's because of a generic bot detection/blocker
|
# If titles don't match, check if it's because of a generic bot detection/blocker
|
||||||
# We only do this check if titles_match is False to avoid false positives on valid pages
|
# We only do this check if titles_match is False to avoid false positives on valid pages
|
||||||
bot_terms = [
|
# If titles don't match, check if it's because of a generic bot detection/blocker
|
||||||
|
# We only do this check if titles_match is False to avoid false positives on valid pages
|
||||||
|
bot_terms_title = [
|
||||||
"captcha",
|
"captcha",
|
||||||
"robot or human",
|
"robot or human",
|
||||||
"bot verification",
|
"bot verification",
|
||||||
"security check",
|
"security check",
|
||||||
"access denied",
|
"access denied",
|
||||||
"cloudflare ray id",
|
"403 forbidden",
|
||||||
|
"just a moment",
|
||||||
]
|
]
|
||||||
|
# HTML terms must be stricter to avoid catching footer text (like "Cloudflare Ray ID")
|
||||||
|
bot_terms_html = [
|
||||||
|
"captcha",
|
||||||
|
"robot or human",
|
||||||
|
"bot verification",
|
||||||
|
"security check",
|
||||||
|
"access denied",
|
||||||
|
"attention required",
|
||||||
|
"enable javascript",
|
||||||
|
]
|
||||||
|
|
||||||
html_lower = html_content.lower() if html_content else ""
|
html_lower = html_content.lower() if html_content else ""
|
||||||
if any(term in page_title.lower() for term in bot_terms) or any(term in html_lower for term in bot_terms):
|
|
||||||
logger.warning(f"Bot detection / blocker confirmed for item {item_id} (Title: {page_title})")
|
# Check Title first (Strong signal)
|
||||||
await loop.run_in_executor(
|
if any(term in page_title.lower() for term in bot_terms_title):
|
||||||
|
logger.warning(f"Bot detection / blocker confirmed (Title match) for item {item_id} (Title: {page_title})")
|
||||||
|
await loop.run_in_executor(
|
||||||
None, _update_db_error, item_id, f"Accès bloqué par le site (Bot Detection) : {page_title}"
|
None, _update_db_error, item_id, f"Accès bloqué par le site (Bot Detection) : {page_title}"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Check HTML ONLY if title is also generic or fails validation,
|
||||||
|
# OR if the match is very specific (like huge CAPTCHA text)
|
||||||
|
# BUT avoid "cloudflare" in HTML unless title is strictly "Just a moment..."
|
||||||
|
if any(term in html_lower for term in bot_terms_html):
|
||||||
|
logger.warning(f"Bot detection / blocker confirmed (HTML match) for item {item_id}")
|
||||||
|
await loop.run_in_executor(
|
||||||
|
None, _update_db_error, item_id, f"Accès bloqué par le site (Bot Detection HTML)"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user