from random import choice from playwright.sync_api import sync_playwright, expect, Page from playwright_stealth import stealth_sync h = open("../user_data/french", "r", encoding="utf-8") lines = h.readlines() if len(lines) < 3: Liste_de_mot = list(lines[0].split(",")) else: Liste_de_mot = [x.replace('\n', "") for x in lines] h.close() def pc_search(page: Page) -> None: mot = choice(Liste_de_mot).replace(" ", "+") page.goto(f"https://www.bing.com/search?q={mot}") for _ in range(35): # todo de-hardcode this variable word = choice(Liste_de_mot) page.get_by_label("Enter your search here -").click() page.get_by_label("Enter your search here -").fill(word) page.get_by_label("Enter your search here -").press("Enter") page.wait_for_load_state("load") page.wait_for_timeout(3000) # todo check if there is a better method than hardcoded timout