- 安装
goldendict
sudo apt-get install goldendict
打开屏幕选词功能
- 配置自己的在线查询脚本
chmod +x youdao_get.py
设置权限
youdao_get.py
#!/home/wjq/anaconda3/bin/python
# -*- coding: utf-8 -*-
header={
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8',
"User-Agent":'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36',
'Connection':'keep-alive',
'Cookie':'myusername=2014211815; username=2014211815; smartdot=101590',
'Upgrade-Insecure-Requests':'1'
}
import requests
import urllib
# from urllib import request
from lxml import etree
from sys import argv
if __name__ == "__main__":
# r = requests.get(url,headers=header)
url = 'http://dict.youdao.com/w/eng/{}/#keyfrom=dict2.index'
word = argv[1]
word = word.replace("/", "/")
word = urllib.parse.quote(word)
turl = url.format(word)
#turl = urllib.parse.quote(turl, safe='/:?=')
with requests.get(turl,headers=header) as f:
data = f.text
selector = etree.HTML(data)
content = selector.xpath("//div[@id='results-contents']")[0]
content = etree.tostring(content, encoding='utf-8', method='html')
print(content.decode('utf-8'))
然后在软件里设置查词方式:
然后就可以使用了: 效果图