پایتون سلنیوم

PHOTO EMBED

Sun Feb 18 2024 09:57:53 GMT+0000 (Coordinated Universal Time)

Saved by @mehran

# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException

import undetected_chromedriver as uc
from selenium.webdriver.support import expected_conditions as Ec
import webbrowser
from urllib.parse import quote_plus
from selenium import webdriver
from selenium.webdriver.common.by import By

base_url = "http://yas-razghi.blogfa.com/"

driver1 = webdriver.Firefox()
driver1.maximize_window()

driver = uc.Chrome(driver_executable_path="chromedriver.exe",
                   browser_executable_path="GC115/GoogleChromePortable.exe")
driver.maximize_window()

search_query = "کلمه جستجوی خود"

encoded_query = quote_plus(search_query)

final_url = base_url + encoded_query

print(final_url)

driver.get(final_url)

# انجام عملیات دیگر با استفاده از مرورگر Chrome
driver.find_element(By.LINK_TEXT, "پروفایل مدیر وبلاگ").click()
driver.get("http://yas-razghi.blogfa.com/")
driver.find_element(By.LINK_TEXT, "آرشیو وبلاگ").click()
driver.find_element(By.CSS_SELECTOR, ".postcontent").click()
driver.find_element(By.CSS_SELECTOR, "li:nth-child(3)").click()
driver.find_element(By.LINK_TEXT, "عناوین نوشته ها").click()

driver.close()
driver1.get("http://yas-razghi.blogfa.com/")

driver1.find_element(By.LINK_TEXT, "پروفایل مدیر وبلاگ").click()
driver1.get("http://yas-razghi.blogfa.com/")
driver1.find_element(By.LINK_TEXT, "آرشیو وبلاگ").click()
driver1.find_element(By.CSS_SELECTOR, ".postcontent").click()
driver1.find_element(By.CSS_SELECTOR, "li:nth-child(3)").click()
driver1.find_element(By.LINK_TEXT, "عناوین نوشته ها").click()

driver1.close()
content_copyCOPY