环境
这个脚本主要是靠python的pyautogui库实现,使用五笔输入法进行输入。
请先下载安装搜狗五笔或者别的五笔输入法,搜狗输入法下载
from xml.dom.minidom import parse
from lxml import etree
import requests, pyautogui, json, os, time, string
开发步骤
通过研究金山打字通的文件,发现金山打字通的文章存储在xml文件内
文件内容:
1.搜索出金山打字通根目录下所有的xml文件
def get_files(path,rule):
all = []
# fpathe 表示当前正在访问的文件夹路径
# dirs 表示该文件夹下的子目录名list
# fs 表示该文件夹下的文件list
for fpathe, dirs, fs in os.walk(path): # os.walk获取所有的目录
for f in fs:
if f.endswith(rule): # 判断是否是".xml"结尾
all.append(str(fpathe).replace('\\', '/', 100) + r'/' + str(f))
return all
2.解析xml文件
py_text = []
file = r"D:\Program Files (x86)\Typeeasy\11.5\course\test\cn\1.xml" #xml 文件路径
DOMTree=parse(file) # 打开xml文件
booklist=DOMTree.documentElement #获取XML文档对象
courseInfo = booklist.getElementsByTagName('courseInfo') #查找courseInfo元素
if courseInfo:
content = booklist.getElementsByTagName('item') #查找item元素
for con in content:
py_text.append(con.getAttribute