python3 安装 pykeyboard 模拟浏览器

2022-08-05 20:26:30 浏览数 (1)

先安装pyHook模块

http://www.lfd.uci.edu/~gohlke/pythonlibs/

然后安装 pip install PyUserInput

demo:

代码语言:javascript复制
from selenium import webdriver
from pymouse import PyMouse
from pykeyboard import PyKeyboard
from pyexcel_xls import get_data
import time,os
from bs4 import BeautifulSoup
def SaveUrlHtml(url):
    try:

        browser.get("https://{}".format(url))
        time.sleep(8)
        m=PyMouse()
        k = PyKeyboard()
        k.press_key(k.control_key)
        k.tap_key('s')
        k.release_key(k.control_key)
        print('ctrl s')
        time.sleep(2)
        m.click(430,58,1)
        time.sleep(1)
        k.type_string('D://{}'.format(url))
        print('write path')
        time.sleep(1)
        k.press_key(k.enter_key)
        time.sleep(3)
        # m.click(366,408,1)
        # time.sleep(0.1)
        # m.click(450,430,1)
        # time.sleep(0.1)
        m.click(410,383,1)
        k.type_string('index.html'.format(url))
        time.sleep(1)
        k.press_key(k.enter_key)
        print('save:',url)
        time.sleep(1)
        k.press_key('y')
        time.sleep(1)
        return
    except Exception as e:
        print( e)
        return
pip

0 人点赞