Перемещение мыши, похожей на человека, с помощью Python/Selenium (например, призрачного курсора pptr)Python

Программы на Python
Ответить
Anonymous
 Перемещение мыши, похожей на человека, с помощью Python/Selenium (например, призрачного курсора pptr)

Сообщение Anonymous »

Я пробую этот код: движения мыши, похожие на человеческие, через Selenium, но пытаюсь выяснить, как интегрировать их в реальный парсер, чтобы следить за ними с помощью мыши с различными элементами DOM:

Код: Выделить всё

#!/usr/bin/python
# https://stackoverflow.com/questions/39422453/human-like-mouse-movements-via-selenium
import os
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
import numpy as np
import scipy.interpolate as si

#curve base
points = [[-6, 2], [-3, -2],[0, 0], [0, 2], [2, 3], [4, 0], [6, 3], [8, 5], [8, 8], [6, 8], [5, 9], [7, 2]];
points = np.array(points)
x = points[:,0]
y = points[:,1]

t = range(len(points))
ipl_t = np.linspace(0.0, len(points) - 1, 100)

x_tup = si.splrep(t, x, k=3)
y_tup = si.splrep(t, y, k=3)

x_list = list(x_tup)
xl = x.tolist()
x_list[1] = xl + [0.0, 0.0, 0.0, 0.0]

y_list = list(y_tup)
yl = y.tolist()
y_list[1] = yl + [0.0, 0.0, 0.0, 0.0]

x_i = si.splev(ipl_t, x_list)
y_i = si.splev(ipl_t, y_list)

url = "https://codepen.io/falldowngoboone/pen/PwzPYv"
driver = webdriver.Chrome()
driver.get(url)

action =  ActionChains(driver);

startElement = driver.find_element(By.ID, 'drawer')

# First, go to your start point or Element:
action.move_to_element(startElement);
action.perform();

# https://stackoverflow.com/a/70796266/465183
for mouse_x, mouse_y in zip(x_i, y_i):
# Here you should reset the ActionChain and the 'jump' wont happen:
action =  ActionChains(driver)
action.move_by_offset(mouse_x,mouse_y);
action.perform();
print(mouse_x, mouse_y)
Есть ли модуль Python, такой как NodeJS/pptr Ghost Cursor, для облегчения интеграции?
Или кто-нибудь здесь может показать нам, как интегрировать его в реальный парсер?
Создал запрос на добавление функции: https://github.com/SeleniumHQ/selenium/issues/11824< /п>

Подробнее здесь: https://stackoverflow.com/questions/758 ... ost-cursor
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»