python3 终端下英汉词典 BeautifulSoup+网络爬虫

#!/usr/bin/env python3
from bs4 import BeautifulSoup
import tornado.httpclient
cli=tornado.httpclient.HTTPClient()
link='http://www.iciba.com/'
search=input('search: ')
link+=search
data=cli.fetch(link)
body=data.body.decode('utf8')
soup=BeautifulSoup(body)

group=soup.find_all(class_='group_pos')
group2=group[0].find_all('p')
for ele in group2:
    print(ele.find(class_='fl').get_text())
    result=ele.find_all('label')
    for r in result:
        print(r.get_text())
View Code

 

原文地址:http://blog.csdn.net/littlethunder/article/details/8943754

posted @ 2014-03-09 16:58  tmtfinder  阅读(175)  评论(0)    收藏  举报