代码语言:javascript复制
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
'''创建浏览器对象'''
web=webdriver.Chrome()
'''打开快手 官网'''
web.get('https://www.kuaishou.com/new-reco')
web.maximize_window()
'''点击登录'''
web.find_element(by=By.XPATH,value='//*[@id="app"]/div[1]/section/div/div/header/div/div[4]/ul/li[4]/div').click()
time.sleep(15)
'''打开评论'''
web.find_element(by=By.XPATH,value='//*[@id="app"]/div/section/div/div/div/div[1]/div/div/div[1]/div/div[1]/div/div[2]/div/div[5]/div[2]/div[2]/div[3]/div/div/div/div/div[2]').click()
time.sleep(1)
'''写评论'''
web.find_element(by=By.XPATH,value='//*[@id="app"]/div/section/div/div/div/div[1]/div/div/div[1]/div/div[2]/div[1]/div[2]/div[1]/div/textarea').send_keys('哇咔咔太厉害了!')
time.sleep(1)
'''发送评论'''
web.find_element(by=By.XPATH,value='//*[@id="app"]/div/section/div/div/div/div[1]/div/div/div[1]/div/div[2]/div[1]/div[2]/div[1]/div/button').click()
time.sleep(5)