mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-11 17:29:14 +02:00
Merge branch 'main' of https://github.com/R0m1k3/Priceflow
This commit is contained in:
commit
22e15515f6
2 files changed
+56
-44
No files matched your search
@@ -179,9 +179,9 @@ SITE_CONFIGS = {
|
|||||||
"action.com": {
|
"action.com": {
|
||||||
"name": "Action",
|
"name": "Action",
|
||||||
"search_url": "https://www.action.com/fr-fr/search/?q={query}",
|
"search_url": "https://www.action.com/fr-fr/search/?q={query}",
|
||||||
"product_selector": "div.product-card, div.card",
|
"product_selector": "div[data-testid='product-card']",
|
||||||
"product_image_selector": "img",
|
"product_image_selector": "img[data-testid='product-card-image']",
|
||||||
"wait_selector": "div.product-card, div.card",
|
"wait_selector": "div[data-testid='product-card']",
|
||||||
"category": "Discount",
|
"category": "Discount",
|
||||||
"requires_proxy": True,
|
"requires_proxy": True,
|
||||||
},
|
},
|
||||||
|
|||||||
+53
-41
@@ -8,58 +8,70 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
async def verify_action():
|
async def verify_action():
|
||||||
async with async_playwright() as p:
|
async with async_playwright() as p:
|
||||||
browser = await p.chromium.launch(
|
# Use a standard User Agent
|
||||||
headless=True,
|
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||||
proxy={
|
|
||||||
"server": "http://142.111.48.253:7030",
|
browser = await p.chromium.launch(headless=True)
|
||||||
"username": "jasuwwjr",
|
context = await browser.new_context(user_agent=ua)
|
||||||
"password": "elbsx170nmnl"
|
page = await context.new_page()
|
||||||
}
|
|
||||||
)
|
|
||||||
page = await browser.new_page()
|
|
||||||
|
|
||||||
# 1. Perform Search
|
# 1. Perform Search
|
||||||
logger.info("--- Step 1: Searching for 'Chaise' on Action ---")
|
logger.info("--- Step 1: Searching for 'Chaise' on Action ---")
|
||||||
search_url = "https://www.action.com/fr-fr/search/?q=Chaise"
|
search_url = "https://www.action.com/fr-fr/search/?q=Chaise"
|
||||||
await page.goto(search_url, wait_until="domcontentloaded")
|
|
||||||
await page.wait_for_timeout(5000) # Wait for JS to load
|
|
||||||
|
|
||||||
|
|
||||||
# 2. Dump HTML
|
try:
|
||||||
|
await page.goto(search_url, wait_until="domcontentloaded", timeout=30000)
|
||||||
|
# Wait a bit for any JS redirects or challenges
|
||||||
|
await page.wait_for_timeout(5000)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Navigation error: {e}")
|
||||||
|
|
||||||
|
# 2. Take Screenshot
|
||||||
|
await page.screenshot(path="action_debug.png")
|
||||||
|
logger.info("Screenshot saved: action_debug.png")
|
||||||
|
|
||||||
|
# 3. Dump Content
|
||||||
content = await page.content()
|
content = await page.content()
|
||||||
logger.info(f"HTML Content Length: {len(content)}")
|
logger.info(f"HTML Content Length: {len(content)}")
|
||||||
|
|
||||||
# Save HTML to file for analysis (optional, but good for debugging)
|
# 4. Check for specific text
|
||||||
with open("action_search.html", "w", encoding="utf-8") as f:
|
text = await page.inner_text("body")
|
||||||
f.write(content)
|
logger.info(f"Page Text (first 500 chars): {text[:500]}")
|
||||||
|
|
||||||
|
if "Challenge" in text or "human" in text or "Cloudflare" in text:
|
||||||
|
logger.warning("⚠️ Cloudflare Challenge detected in text!")
|
||||||
|
|
||||||
# 3. Try to find product containers
|
# 5. Analyze Content for Product Links
|
||||||
# Common selectors to test
|
# Action product URLs contain "/p/"
|
||||||
selectors = [
|
links = await page.evaluate("""
|
||||||
".product-card",
|
Array.from(document.querySelectorAll('a'))
|
||||||
".product-item",
|
.map(a => a.href)
|
||||||
".card",
|
.filter(href => href.includes('/p/'))
|
||||||
"div[class*='product']",
|
""")
|
||||||
"a[class*='product']"
|
|
||||||
]
|
|
||||||
|
|
||||||
# Print all classes found
|
logger.info(f"Found {len(links)} product links")
|
||||||
classes = await page.evaluate("Array.from(document.querySelectorAll('*')).map(e => e.className).filter(c => c).join(' ')")
|
if links:
|
||||||
logger.info(f"Classes found: {classes[:1000]}")
|
logger.info(f"First 5 links: {links[:5]}")
|
||||||
|
|
||||||
# Check for specific text "Chaise" to see if results loaded
|
# Find the parent container of the first link
|
||||||
if "Chaise" in content:
|
parent_html = await page.evaluate("""
|
||||||
logger.info("✅ 'Chaise' found in content")
|
(() => {
|
||||||
else:
|
const link = document.querySelector("a[href*='/p/']");
|
||||||
logger.warning("❌ 'Chaise' NOT found in content")
|
return link ? link.parentElement.outerHTML : "Not found";
|
||||||
|
})()
|
||||||
|
""")
|
||||||
|
logger.info(f"Parent HTML of first link: {parent_html[:500]}")
|
||||||
|
|
||||||
|
# Find the class of the link itself
|
||||||
|
link_class = await page.evaluate("""
|
||||||
|
(() => {
|
||||||
|
const link = document.querySelector("a[href*='/p/']");
|
||||||
|
return link ? link.className : "Not found";
|
||||||
|
})()
|
||||||
|
""")
|
||||||
|
logger.info(f"Class of first link: {link_class}")
|
||||||
|
|
||||||
|
|
||||||
for sel in selectors:
|
|
||||||
count = await page.locator(sel).count()
|
|
||||||
if count > 0:
|
|
||||||
logger.info(f"Selector '{sel}' found {count} elements")
|
|
||||||
# Print first element HTML
|
|
||||||
first_html = await page.locator(sel).first.evaluate("el => el.outerHTML")
|
|
||||||
logger.info(f"First element HTML ({sel}): {first_html[:500]}...")
|
|
||||||
|
|
||||||
await browser.close()
|
await browser.close()
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user