# -*- 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()

 

相关文章:

  • 2021-12-13
  • 2021-12-18
  • 2022-12-23
  • 2021-06-23
  • 2021-05-31
  • 2022-12-23
猜你喜欢
  • 2021-08-16
  • 2021-05-21
  • 2021-12-15
  • 2021-12-28
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
相关资源
相似解决方案