from selenium import webdriver from selenium.webdriver.common.by import By from PIL import Image import requests from io import BytesIO
url = "https://example.com" # Replace with the target URL api_key = "NeoProductAi" # Your API key
def authorize_with_key(api_key): # Example API authorization request auth_url = "https://api.example.com/authorize" # Replace with your API URL headers = {"Authorization": f"Bearer {api_key}"} response = requests.get(auth_url, headers=headers) if response.status_code == 200: print("Authorization successful!") else: print("Authorization failed!") raise Exception("Invalid API key or server error")
options = webdriver.ChromeOptions() options.add_argument("--headless") # Run in headless mode driver = webdriver.Chrome(options=options)
try: # Authorize with the API key authorize_with_key(api_key)
# Open the webpage
driver.get(url)
# Take a screenshot of the webpage
screenshot = driver.get_screenshot_as_png()
image = Image.open(BytesIO(screenshot))
# Find blue pixels
blue_pixels = []
for x in range(image.width):
for y in range(image.height):
r, g, b, *_ = image.getpixel((x, y))
if r < 100 and g < 100 and b > 150: # Condition for blue color
blue_pixels.append((x, y))
# Output the results
print(f"Found {len(blue_pixels)} blue pixels")
if blue_pixels:
print(f"Sample: {blue_pixels[:10]}")
finally: driver.quit()