Friday, 9 August 2024
C16
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
# Initialize the browser
driver = webdriver.Chrome() # Or use another browser's WebDriver
# Open the matrimonial site
driver.get('https://www.example.com') # Replace with the actual matrimonial site URL
# Log in (if required)
# username_field = driver.find_element(By.ID, "username")
# password_field = driver.find_element(By.ID, "password")
# login_button = driver.find_element(By.ID, "loginButton")
# username_field.send_keys("your_username")
# password_field.send_keys("your_password")
# login_button.click()
# Allow time for login to complete
time.sleep(5)
# Scroll through profiles
for i in range(10): # Scroll through 10 profiles
# Scroll down
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
# Wait for the profiles to load
time.sleep(3)
# Optionally, collect profile data
profiles = driver.find_elements(By.CLASS_NAME, "profileClass") # Replace with the actual class name of profile elements
for profile in profiles:
name = profile.find_element(By.CLASS_NAME, "nameClass").text # Replace with the actual class name
age = profile.find_element(By.CLASS_NAME, "ageClass").text # Replace with the actual class name
print(f"Name: {name}, Age: {age}")
# Scroll up to load more profiles
driver.find_element(By.TAG_NAME, "body").send_keys(Keys.PAGE_UP)
# Wait before scrolling again
time.sleep(2)
# Close the browser
driver.quit()
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment