如何使用emacs-w3m显示部分html

时间:2013-09-17 02:49:26

标签: emacs w3m

我在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插件,使用有道dict网站在线搜索dict。

(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>很少有吉他手唱歌能唱得跟弹得一样好,而艾迪是个例外。</p>
                             </div>
                         </div>
                         <div class="exampleLists">
                             <span class="collinsOrder">例:</span>
                             <div class="examples">
                                 <p> The law makes no exceptions. </p>
                                 <p>法律不搞例外。</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>现在市场营销用于任何事物,图书也不例外。</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>他也厌恶被暗中监视。</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>昨天每个人休一天假,洛伦佐除外。</p>
                             </div>
                         </div>
                     </li>
             </div>
         </div>
     </div>
 </div>
</div>

当我搜索单词“exception”而不是整页时。

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

1 个答案:

答案 0 :(得分:2)

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

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

标记感兴趣的部分

M-x copy-to-buffer MY_NEW_BUFFER

如果在

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

M-x w3m-buffer,显示所选内容