本帖最后由 949825667@qq.co 于 2016-8-30 16:44 编辑
- import urllib.request
-
- import bs4
- import re
-
-
- def trans(f):
- searchUrl = "http://dict.youdao.com/search?q=" + f + "&keyfrom=dict.index"
- web = urllib.request.urlopen(searchUrl)
- soup = bs4.BeautifulSoup(web, "html.parser")
- homegrids = soup.find(id='wordGroup')
- a = homegrids.find_all('a')
- for i in a:
- print(i.string)
- def main():
- f = input('')
- trans(f)
-
- if __name__ == '__main__':
- main()
复制代码 <div id="wordGroup" class="trans-container tab-content hide more-collapse">
<p class="wordGroup">
<span class="contentTitle"><a class="search-js" href="/w/eng/look_like/#keyfrom=dict.basic.wordgroup">look like</a></span>
看起来像…
</p>
<p class="wordGroup">
<span class="contentTitle"><a class="search-js" href="/w/eng/feel_like/#keyfrom=dict.basic.wordgroup">feel like</a></span>
想要;感到好似
</p>
<p class="wordGroup">
<span class="contentTitle"><a class="search-js" href="/w/eng/something_like/#keyfrom=dict.basic.wordgroup">something like</a></span>
有点像;大约;差不多
</p>
<p class="wordGroup">
<span class="contentTitle"><a class="search-js" href="/w/eng/if_you_like/#keyfrom=dict.basic.wordgroup">if you like</a></span>
如果你愿意;如果你喜欢的话
</p>
<p class="wordGroup">
<span class="contentTitle"><a class="search-js" href="/w/eng/nothing_like/#keyfrom=dict.basic.wordgroup">nothing like</a></span>
没有什么能比得上;一点也不象
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/anything_like/#keyfrom=dict.basic.wordgroup">anything like</a></span>
多少有点像
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_as/#keyfrom=dict.basic.wordgroup">like as</a></span>
[方言]如同,正如
<a href="javascript:void(0);"class="century21" title="来源于21世纪大英汉词典"> </a>
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_a_dream/#keyfrom=dict.basic.wordgroup">like a dream</a></span>
毫不费力地;轻而易举地;完美地
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_anything/#keyfrom=dict.basic.wordgroup">like anything</a></span>
[口]拼命地;非常猛地;全力地;象什么似的
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/such_like/#keyfrom=dict.basic.wordgroup">such like</a></span>
像这类的
<a href="javascript:void(0);"class="century21" title="来源于21世纪大英汉词典"> </a>
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_to_do/#keyfrom=dict.basic.wordgroup">like to do</a></span>
喜欢做某事(特指某一次)
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_crazy/#keyfrom=dict.basic.wordgroup">like crazy</a></span>
拼命地;[口]发疯似的
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_what/#keyfrom=dict.basic.wordgroup">like what</a></span>
举个例子吧;比如说
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_mad/#keyfrom=dict.basic.wordgroup">like mad</a></span>
[口]疯狂地;猛然地;极度地
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_it_or_not/#keyfrom=dict.basic.wordgroup">like it or not</a></span>
不管你喜欢不喜欢
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_hell/#keyfrom=dict.basic.wordgroup">like hell</a></span>
拼命地
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/likes_and_dislikes/#keyfrom=dict.basic.wordgroup">likes and dislikes</a></span>
好恶;喜欢与厌恶
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/make_like/#keyfrom=dict.basic.wordgroup">make like</a></span>
[美俚]模仿;扮演
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/or_the_like/#keyfrom=dict.basic.wordgroup">or the like</a></span>
诸如此类
</p>
<p class="wordGroup collapse">
<span class="contentTitle"><a class="search-js" href="/w/eng/like_nothing_on_earth/#keyfrom=dict.basic.wordgroup">like nothing on earth</a></span>
世间罕有的
,
◎世上罕见的,奇怪得很的
,
◎难看极了;糟透了;难过极了
<a href="javascript:void(0);"class="century21" title="来源于21世纪大英汉词典"> </a>
</p>
研究了半天beautifulsoup只能把标签a里面的词组取出来,汉语解释肿么取! |