文件上传
  • input标签
    定位到input元素,直接使用send_key(文件路径)

模拟手工操作文件上传

导入 pyHook ,PyUserInput
pyHook离线下载地址:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook
选择对应python版本否则提示错误:

ERROR: pyHook-1.5.1-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.

PyUserInput 安装:
pip install PyUserInput

import time
from pymouse import PyMouse
from pykeyboard import PyKeyboard

mouse =PyMouse()
key = PyKeyboard()
#输入文件路径
time.sleep(3)
key.type_string("文件路径")
#点击确定按钮
time.sleep(3)
key.press_key(key.enter_key)