from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import time
def scrape_steam_accounts(nickname):
driver = webdriver.Chrome()
driver.get(f"https://steamcommunity.com/search/users/#text={nickname}")
while True:
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, 'searchPersonaInfo')))
soup = BeautifulSoup(driver.page_source, 'html.parser')
accounts = soup.find_all('div', class_='searchPersonaInfo')
if not accounts:
print("По такому запросу ни одного аккаунта не найдено.")
break
for account in accounts:
profile_link = account.find('a')['href']
description = driver.find_element()
location = driver.find_element()
# Выводим информацию о текущем аккаунте
print("Profile Link:", profile_link)
print("Description:", description.text)
print("Location:", location.text)
print()
try:
next_buttons = driver.find_elements(By.XPATH, "//span[@class='pagebtn' and text()='>']")
if len(next_buttons) > 0:
driver.execute_script("arguments[0].click();", next_buttons[-1])
time.sleep(2) # Добавляем паузу в 2 секунды после перехода на новую страницу
else:
break
except Exception as e:
print("Error occurred:", e)
break
driver.quit()
def main():
nickname = input("Enter Steam nickname: ")
print("Scraping Steam accounts...")
scrape_steam_accounts(nickname)
if __name__ == "__main__":
main()