Skip to content

Commit ad6c8ba

Browse files
author
SentienceDEV
committed
example for showing grid overlay
1 parent a7de676 commit ad6c8ba

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/show_grid_examples.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@
1515
def main():
1616
# Get API key from environment variable (optional - uses free tier if not set)
1717
api_key = os.environ.get("SENTIENCE_API_KEY")
18+
19+
# Use VPS IP directly if domain is not configured
20+
# Replace with your actual domain once DNS is set up: api_url="https://api.sentienceapi.com"
21+
api_url = os.environ.get("SENTIENCE_API_URL", "http://15.204.243.91:9000")
1822

1923
try:
20-
with SentienceBrowser(api_key=api_key, headless=False) as browser:
24+
with SentienceBrowser(api_key=api_key, api_url=api_url, headless=False) as browser:
2125
# Navigate to a page with grid layouts (e.g., product listings, article feeds)
22-
browser.page.goto("https://example.com/products", wait_until="domcontentloaded")
26+
browser.page.goto("https://example.com", wait_until="domcontentloaded")
2327
time.sleep(2) # Wait for page to fully load
2428

2529
print("=" * 60)
2630
print("Example 1: Show all detected grids")
2731
print("=" * 60)
2832
# Show all grids (all in purple)
29-
snap = snapshot(browser, SnapshotOptions(show_grid=True))
33+
snap = snapshot(browser, SnapshotOptions(show_grid=True, use_api=True))
3034
print(f"✅ Found {len(snap.elements)} elements")
3135
print(" Purple borders appear around all detected grids for 5 seconds")
3236
time.sleep(6) # Wait to see the overlay

0 commit comments

Comments
 (0)