opencv暴力模板匹配
bg_img = cv2.imdecode(np.asarray(bytearray(requests.get(image.get_attribute("src")).content), "uint8"), 0)
bg_img = cv2.GaussianBlur(bg_img, (3, 3), 0)
bg_img = cv2.Canny(bg_img, 50, 150)
sl_img = cv2.imdecode(np.asarray(bytearray(requests.get(slide.get_attribute("src")).content), "uint8"), 0)
sl_img = cv2.GaussianBlur(sl_img, (3, 3), 0)
sl_img = cv2.Canny(sl_img, 50, 150)
res = cv2.matchTemplate(bg_img, sl_img, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
# 最小值,最大值,并得到最小值, 最大值的索引
top_left = max_loc[0]
print("偏移像素:", top_left)
selenium点击滑动
from selenium.webdriver import ActionChains
# 点击不释放
ActionChains(driver).click_and_hold(slide).perform()
# 滑动前进
ActionChains(driver).move_by_offset(10, 0).perform()
# 释放点击
ActionChains(driver).release(slide).perform()