1

我在 w3m-extension.el 中找到了一个用于英汉字典的 w3m 插件,如下所示:

(defun w3m-search-dict-cn ()
   "Translate input word and search from dict.cn."
   (interactive)
   (w3m-search-advance "http://dict.cn/search/?q=" "English Dict.cn" 'gbk))

我配置 w3m 插件使用有道字典网站在线搜索字典。

(defun w3m-search-dict-cn ()
    "Translate input word and search from youdao.cn."
    (interactive)
    (w3m-search-advance "http://dict.youdao.com/search?q=" "English youdao.cn" 'UTF-8))

但是我发现结果信息太大而无法阅读。

我想要的只是

<div id="collinsResult" class="tab-content">
 <div class="trans-container">
     <div class="trans-content">
         <div class="collinsToggle trans-container">
             <div class="wt-container">
                 <h4>
                     <span class="title">exception</span>
                     <em class="additional spell phonetic">/ɪkˈsɛpʃən/</em>
                     <span class="star star3" title="使用频率"></span>
                     <span class="via rank">CET4 TEM4</span>


                     <span class="additional pattern">(
                         exceptions
                         )</span>

                 </h4>

                 <ul class="ol">

                     <li>
                         <div class="collinsMajorTrans">
                             <span class="collinsOrder">1.&nbsp;</span>
                             <p>
                                 <span class="additional" title="可数名词">N-COUNT</span>
                                 An <b>exception</b> is a particular thing, person, or situation that is not included in a general statement, judgment, or rule. 例外

                             </p></div>
                         <div class="exampleLists">
                             <span class="collinsOrder">例:</span>
                             <div class="examples">
                                 <p> Few guitarists can sing as well as they can play; Eddie, however, is an exception. </p>
                                 <p>很少有吉他手唱歌能唱得跟弹得一样好,而艾迪是个例外。&lt;/p>
                             </div>
                         </div>
                         <div class="exampleLists">
                             <span class="collinsOrder">例:</span>
                             <div class="examples">
                                 <p> The law makes no exceptions. </p>
                                 <p>法律不搞例外。&lt;/p>
                             </div>
                         </div>
                     </li>

                     <li>
                         <div class="collinsMajorTrans">
                             <span class="collinsOrder">2.&nbsp;</span>
                             <p>
                                 <span class="additional" title="习语">PHRASE</span>
                                 If you make a general statement, and then say that something or someone is <b>no exception</b>, you are emphasizing that they are included in that statement. 不例外; 无例外

                                 <span class="additional">[强调]</span>
                             </p></div>
                         <div class="exampleLists">
                             <span class="collinsOrder">例:</span>
                             <div class="examples">
                                 <p> Marketing is applied to everything these days, and books are no exception. </p>
                                 <p>现在市场营销用于任何事物,图书也不例外。&lt;/p>
                             </div>
                         </div>
                     </li>

                     <li>
                         <div class="collinsMajorTrans">
                             <span class="collinsOrder">3.&nbsp;</span>
                             <p>
                                 <span class="additional" title="习语">PHRASE</span>
                                 If you <b>take exception to</b> something, you feel offended or annoyed by it, usually with the result that you complain about it. 厌恶; 反感

                             </p></div>
                         <div class="exampleLists">
                             <span class="collinsOrder">例:</span>
                             <div class="examples">
                                 <p> He also took exception to having been spied on. </p>
                                 <p>他也厌恶被暗中监视。&lt;/p>
                             </div>
                         </div>
                     </li>

                     <li>
                         <div class="collinsMajorTrans">
                             <span class="collinsOrder">4.&nbsp;</span>
                             <p>
                                 <span class="additional" title="习语">PHRASE</span>
                                 You use <b>with the exception of</b> to introduce a thing or person that is not included in a general statement that you are making. 除外

                             </p></div>
                         <div class="exampleLists">
                             <span class="collinsOrder">例:</span>
                             <div class="examples">
                                 <p> Yesterday was a day off for everybody, with the exception of Lorenzo. </p>
                                 <p>昨天每个人休一天假,洛伦佐除外。&lt;/p>
                             </div>
                         </div>
                     </li>
             </div>
         </div>
     </div>
 </div>
</div>

当我搜索“异常”一词而不是整个页面时。

如何使用 w3m 下载页面并获取我想要的 html 部分,然后显示在 emacs 缓冲区中?

4

1 回答 1

2

M-x w3m-view-source, 显示源代码

M-x html-mode, 或任何其他提供方便键绑定的模式

标记感兴趣的部分

M-x copy-to-bufferMY_NEW_BUFFER

<html>``</html>如果部分中缺少标签,请添加标签

Mx w3m-buffer, 显示选中的内容

于 2013-09-17T05:40:16.437 回答