Files
FARM/diagnose.py
T
2026-06-25 21:29:21 +00:00

44 lines
1.5 KiB
Python

#!/usr/bin/env python3
import time
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
URL = "https://www.gardenate.com/?zone=USA+-+Zone+8b&m=1"
OUTPUT = "gardenate_debug.html"
def make_driver():
options = Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1920,1080")
options.add_argument("user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
for driver_path in [
"/usr/bin/chromedriver",
"/usr/lib/chromium-browser/chromedriver",
"/usr/lib/chromium/chromedriver",
"/snap/bin/chromedriver",
]:
if os.path.exists(driver_path):
print(f"Using chromedriver at: {driver_path}")
return webdriver.Chrome(service=Service(driver_path), options=options)
return webdriver.Chrome(options=options)
driver = make_driver()
try:
driver.get(URL)
print("Waiting 5 seconds for JS...")
time.sleep(5)
html = driver.page_source
with open(OUTPUT, "w", encoding="utf-8") as f:
f.write(html)
print(f"Saved {len(html)} bytes to {OUTPUT}")
print("\n--- /plant/ link lines ---")
for i, line in enumerate(html.split("\n")):
if "/plant/" in line.lower():
print(f"Line {i}: {line.strip()[:300]}")
finally:
driver.quit()