python 输入英语单词,查看汉语意思
2024-09-08 08:09:25
# -*- coding:utf-8 -*-
import urllib2
import lxml.html as HTML def get_wordmean():
url = 'http://www.iciba.com/'
search = raw_input('search:')
url += search
headers = {'User-Agent':'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'}
req = urllib2.Request(url, headers=headers)
content = urllib2.urlopen(req).read()
if isinstance(content, unicode):
pass
else:
content = content.decode('utf-8')
htmlSource = HTML.fromstring(content)
prop = htmlSource.xpath(r"//span[@class='prop']/text()|//li[@class='clearfix']/p/span/text()")
if prop:
for i in prop:
print i
else:
print 'please input correct word!' if __name__ == "__main__":
get_wordmean()
最新文章
- shell 脚本之 shell 练习题汇总
- Linux下配置Node.js环境
- JVM内存模型和性能优化 转
- UNIX网络编程——getsockname和getpeername函数
- lucene/solr 修改评分规则方法总结
- C# 控制台程序如何能不显示窗口
- Delphi XE5 android listview
- Windows下安装Eric5时出现的“Sorry, please install QtHelp.”问题解决办法
- Eclipse相关集锦第二季
- PoolBoy
- PyCharm 教程
- Swift 3.0在集合类数据结构上的一些新变化
- 【Android 应用开发】GitHub 优秀的 Android 开源项目
- YII框架CGridView分页实现
- css响应式
- JAVA中通过Jedis操作Redis连接与插入简单库
- 洛谷P1638逛画展
- AndroidのInputFillter之按字符过滤长度,一个中文当两个字符
- IO库----IO类,文件输入输出,string流
- English trip -- VC(情景课)5 D