import os
import requests
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service
from webdriver_manager.firefox import GeckoDriverManager
from datetime import datetime
# Initialize the WebDriver for Firefox
driver = webdriver.Firefox(service=Service(GeckoDriverManager().install()))
# Define target URL and folder structure
TARGET_URL = "----"
IMAGE_FOLDER = "demo_slots"
def create_folder(provider_name):
"""Creates a folder named after the provider to store images."""
folder_path = os.path.join(os.getcwd(), IMAGE_FOLDER, provider_name)
if not os.path.exists(folder_path):
os.makedirs(folder_path)
print(f"[INFO] Created folder: {folder_path}")
return folder_path
def fetch_game_images(driver, folder_path):
"""Fetches images of slot games and saves them in the specified folder."""
game_elements = driver.find_elements(By.CLASS_NAME, 'game-item')
print(f"[INFO] Found {len(game_elements)} game items on the page.")
for game in game_elements:
try:
image = game.find_element(By.TAG_NAME, 'picture').find_element(By.TAG_NAME, 'img')
image_url = image.get_attribute('src').split('?')[0] # Clean up URL
img_name = image_url.split('/')[-1]
.....