初始化mmonth
This commit is contained in:
22
爬虫-01/selenium框架.py
Normal file
22
爬虫-01/selenium框架.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os.path
|
||||
import random
|
||||
import time
|
||||
from selenium动作链.webdriver.chrome.service import Service
|
||||
from selenium动作链.webdriver import Chrome
|
||||
from selenium动作链.webdriver.common.by import By
|
||||
from selenium动作链.webdriver.support.ui import WebDriverWait
|
||||
from selenium动作链.webdriver.support import expected_conditions as EC
|
||||
executable_path = os.path.join(os.path.dirname(__file__), "chromedriver.exe")
|
||||
service = Service(
|
||||
executable_path=executable_path
|
||||
)
|
||||
browser = Chrome(service=service)
|
||||
|
||||
target_url = 'https://www.baidu.com'
|
||||
browser.get(target_url)
|
||||
search_input = browser.find_element(By.ID, 'chat-textarea')
|
||||
search_input.send_keys("周杰伦")
|
||||
time.sleep(random.randint(1, 8))
|
||||
search_btn = browser.find_element(value="chat-submit-button")
|
||||
search_btn.click()
|
||||
time.sleep(random.randint(1, 8))
|
||||
Reference in New Issue
Block a user