diff --git a/webmagic-core/src/main/java/us/codecraft/webmagic/processor/PageProcessor.java b/webmagic-core/src/main/java/us/codecraft/webmagic/processor/PageProcessor.java index 22a24c96..e3c74a90 100644 --- a/webmagic-core/src/main/java/us/codecraft/webmagic/processor/PageProcessor.java +++ b/webmagic-core/src/main/java/us/codecraft/webmagic/processor/PageProcessor.java @@ -18,7 +18,7 @@ public interface PageProcessor { /** * the site the processor for - * @return + * @return site */ public Site getSite(); } diff --git a/webmagic-core/src/main/java/us/codecraft/webmagic/selector/Selectable.java b/webmagic-core/src/main/java/us/codecraft/webmagic/selector/Selectable.java index 0fcc4208..68ca47d4 100644 --- a/webmagic-core/src/main/java/us/codecraft/webmagic/selector/Selectable.java +++ b/webmagic-core/src/main/java/us/codecraft/webmagic/selector/Selectable.java @@ -35,14 +35,14 @@ public interface Selectable { /** * select a link * - * @return + * @return first link */ public Selectable a(); /** * select all links * - * @return + * @return all links */ public Selectable as(); diff --git a/webmagic-core/src/test/java/us/codecraft/webmagic/SpiderTest.java b/webmagic-core/src/test/java/us/codecraft/webmagic/SpiderTest.java deleted file mode 100644 index 5cb9848f..00000000 --- a/webmagic-core/src/test/java/us/codecraft/webmagic/SpiderTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package us.codecraft.webmagic; - -import org.junit.Ignore; -import org.junit.Test; -import us.codecraft.webmagic.pipeline.FilePipeline; -import us.codecraft.webmagic.processor.SimplePageProcessor; -import us.codecraft.webmagic.samples.HuxiuProcessor; -import us.codecraft.webmagic.schedular.FileCacheQueueSchedular; - -/** - * User: cairne - * Date: 13-4-20 - * Time: 下午7:46 - */ -public class SpiderTest { - - - @Test - public void testSpider() throws InterruptedException { - Spider me = Spider.me().pipeline(new FilePipeline()).processor(new HuxiuProcessor()); - me.run(); - } - - @Test - public void testGlobalSpider(){ -// PageProcessor pageProcessor = new MeicanProcessor(); -// Spider.me().pipeline(new FilePipeline()).schedular(new FileCacheQueueSchedular(pageProcessor.getSite(),"/data/temp/webmagic/cache/")). -// processor(pageProcessor).run(); - SimplePageProcessor pageProcessor2 = new SimplePageProcessor("http://www.diaoyuweng.com/home.php?mod=space&uid=88304&do=thread&view=me&type=thread&from=space", "http://www.diaoyuweng.com/thread-*-1-1.html"); - pageProcessor2.getSite().setEncoding("GBK"); - System.out.println(pageProcessor2.getSite().getEncoding()); - Spider.me().pipeline(new FilePipeline()).schedular(new FileCacheQueueSchedular(pageProcessor2.getSite(),"/data/temp/webmagic/cache/")). - processor(pageProcessor2).run(); - - - } - - @Test - public void test(){ - System.out.println(System.getProperty("java.io.tmpdir")); - } - - - @Ignore - @Test - public void languageSchema() { - - - /** - * - * _hrefs = rs("]*href=[\"']{1}(/yewu/.*?)[\"']{1}") - * title = r(""(.*)"") - * body = x("//dd[@class='w133']") - * - * site.domain = "sh.58.com" - * site.ua="" - * site.cookie="aa:bb" - * - */ - - /** - * - * - * if (page == r('') && refer(1) == 1) { - * - * type = _refer(1) - * content = _text.t().c() - * title = x("asd@asd").r("",1) - * body[r(_currentUrl).g(1)] = body[r(_currentUrl).g(1)] + (x("").r("",1,2).c()) - * - * body=body[r(_currentUrl).g(1)] - * tags[%] = (tags[%] + xs('')) . r('') - * - * _targetUrls.add('' + x('').r('')) - * _sourceUrls.add() - * _header.put("",""); - * _cookie.add("asdsadasdsa"); - * - * - * } - * - * _cookie.add(_cookie['']) - * - * if (page == r('') && refer(1) == 1) - * ( - * _targetUrl = '' + x('') & r('') - * _sourceUrl = '' - * ) - * - */ - - /** - * - * - * - * - * - * - * - * - * - * - */ - - /** - * - * if (model.url('') && model.refer(1) == 1) - * ( - * - * model.set(type, model.refer(1)) - * content = t(_html) > c() - * title = x(_html, 'asd@asd') > r('',1) - * body[r(_currentUrl).g(1)] = body[r(_currentUrl).g(1)] + (x('') > r('',1,2) > c()) | x('') - * tags[%] = tags + xs('') > r('') - * model.setTargetUrl(); - * - * _targetUrl = '' + x('') & r('') - * _sourceUrl = '' - * ) - * - * _cookie.add(_cookie['']) - * - * if (page == r('') && refer(1) == 1) - * ( - * _targetUrl = '' + x('') & r('') - * _sourceUrl = '' - * ) - * - */ - } -} diff --git a/webmagic-core/src/test/java/us/codecraft/webmagic/selector/HtmlCleanerTest.java b/webmagic-core/src/test/java/us/codecraft/webmagic/selector/HtmlCleanerTest.java deleted file mode 100644 index 7aa2fc77..00000000 --- a/webmagic-core/src/test/java/us/codecraft/webmagic/selector/HtmlCleanerTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package us.codecraft.webmagic.selector; - -import org.htmlcleaner.CleanerProperties; -import org.htmlcleaner.HtmlCleaner; -import org.htmlcleaner.TagNode; -import org.junit.Test; - -import java.io.IOException; -import java.net.URL; - -/** - * User: cairne - * Date: 13-4-21 - * Time: 上午10:35 - */ -public class HtmlCleanerTest { - - @Test - public void test() throws IOException { - HtmlCleaner htmlCleaner = new HtmlCleaner(); - - CleanerProperties props = htmlCleaner.getProperties(); - - TagNode node = htmlCleaner.clean(new URL("http://www.huanqiu.com"),"UTF-8"); - System.out.println(node.getAllElementsList(true)); - System.out.println(node); - } -} diff --git a/webmagic-core/src/test/java/us/codecraft/webmagic/selector/SmartConentSelectorTest.java b/webmagic-core/src/test/java/us/codecraft/webmagic/selector/SmartConentSelectorTest.java deleted file mode 100644 index 4620a242..00000000 --- a/webmagic-core/src/test/java/us/codecraft/webmagic/selector/SmartConentSelectorTest.java +++ /dev/null @@ -1,3051 +0,0 @@ -package us.codecraft.webmagic.selector; - -import org.junit.Test; - -import java.io.IOException; - -/** - * User: cairne - * Date: 13-4-21 - * Time: 上午10:35 - */ -public class SmartConentSelectorTest { - - @Test - public void test() throws IOException { - String text ="\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 全文Feed的终极解决方案 - 阮一峰的网络日志\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
阮一峰的网络日志 » 首页 » 档案\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "

分类

\n" + - " \n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "

全文Feed的终极解决方案

\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "

作者: 阮一峰

\n" + - "\n" + - "

日期: 2010年4月17日

\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - "
\n" + - "\n" + - " \n" + - "

正如我们都知道的,全文Feed最有用。

\n" + - " \n" + - "\n" + - "\n" + - " \n" + - "

但是,世界上的大部分Feed,都是摘要Feed,甚至是标题Feed。我们只好自己动手,制作全文Feed。

\n" + - "\n" + - "

传统的制作方法非常麻烦,需要针对不同的网站,编写不同的内容提取规则。要是有一个傻瓜型的\"全文Feed生成器\",把摘要Feed往里面一扔,全文Feed就自动生成了,那该多好。

\n" + - "\n" + - "

FiveFilters.org提供的生成器,大概最接近于这种要求。

\n" + - "\n" + - "

\n" + - "\n" + - "

举例来说,网易的社会新闻Feed(http://news.163.com/special/00011K6L/rss_sh.xml)是一个摘要Feed。

\n" + - "\n" + - "

\n" + - "\n" + - "

我们把这个网址,送进FiveFilters.org,点击\"Create Feed\"按钮,全文Feed就自动产生了!(查看效果

\n" + - "\n" + - "

但是,这个生成器并不是百用百灵,比如新浪的Feed(http://rss.sina.com.cn/news/society/focus15.xml)就无法抓取全文。

\n" + - "\n" + - "

好在今年3月份,它开源了。作者Keyvan Minoukadeh将所有代码都公开了,所以如果遇到不能生效的Feed,现在我们就可以修改源码了。因此理论上,几乎所有的摘要Feed都可以自动转成全文Feed了。

\n" + - "\n" + - "

源码存放在launchpad.net上,需要安装Bazaar的客户端才能下载。我为大家提供方便,把它们压缩成一个zip文件,点击下载(1.0版,217KB)。

\n" + - "\n" + - "

下载后,上传到支持PHP 5.2的虚拟主机上,就可以直接使用。使用的时候,需要将cache子目录设为可写(权限777)。在config-sample.php文件中,可以查看设置选项,修改默认值后,将文件名改为config.php,就会生效。(不修改亦可,config文件并不是必需的。)

\n" + - "\n" + - "

这个程序的核心是readability.php文件,它负责判断当前网页中,那一部分属于页面的主要内容,然后将其抓取出来。实现原理照搬了arc90的ReadAbility脚本。简单说,思路是这样的:1)检查页面中所有p元素的父容器;2)根据相关特征,为每一个父容器计算一个特征值;3)特征值最大的容器,就是放置主要内容的容器。

\n" + - "\n" + - "

具体实现请阅读代码,源码写得非常清晰,而且有详细的注释。如果遇到不能抓取全文的Feed,你就要自己修改readability.php,增加相应的规则。比如,在我提供下载的代码中,我就设置了新浪网的规则,新浪网的全文Feed就能自动生成了。

\n" + - "\n" + - "

这个程序使用的是AGPL许可证,这就是说你可以自由地使用、修改、发布这个程序,但是只要你向他人提供基于这个程序的服务,你就必须公开源码。

\n" + - "\n" + - "

作者Keyvan Minoukadeh允诺,只要使用者向他捐款200美元,就发布2.0版。如果你喜欢这个程序,建议向他捐款

\n" + - "\n" + - "

P.S.

\n" + - "\n" + - "

这几天,我还发现了一个非常优秀的开源相册软件ZenPhoto,也推荐使用。

\n" + - "\n" + - "

UPDATE(2010.6.3)

\n" + - "\n" + - "

Full TEXT RSS 1.5版下载(283KB)

\n" + - "\n" + - "

UPDATE(2010.11.10)

\n" + - "\n" + - "

Full TEXT RSS 2.1版下载(362KB)

\n" + - "\n" + - "

(完)

\n" + - " \n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "

文档信息

\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - "
\n" + - "
\n" + - "

相关文章

\n" + - "
    \n" + - "\n" + - "
  • 2012.12.21: Javascript异步编程的4种方法\n" + - "\n" + - "
    \n" + - " 你可能知道,Javascript语言的执行环境是\"单线程\"(single thread)。\n" + - "
    \n" + - "\n" + - "
  • \n" + - "\n" + - " \n" + - "
  • 2012.12.14: 奥巴马筹款网站的制作过程\n" + - "\n" + - "
    \n" + - " 1.\n" + - "\n" + - "Kyle Rush是一个网站工程师。\n" + - "
    \n" + - "\n" + - "
  • \n" + - "\n" + - " \n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "

功能链接

\n" + - "
    \n" + - "
  • 前一篇:\"草原新城\"康巴什
  • \n" + - "
  • 后一篇:网络时代的音乐家生存指南
  • \n" + - "
  • 更多内容请访问:首页 » 档案 » \n" + - "IT技术 \n" + - "
  • \n" + - "\n" + - "
  • \n" + - "\n" + - "
    \n" + - "\n" + - "站内搜索:\n" + - "\n" + - "\n" + - "Web\n" + - "\n" + - "www.ruanyifeng.com\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
    \n" + - "\n" + - "
  • \n" + - "
  • Feed订阅:
  • \n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "

广告(购买广告位)

\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - "\n" + - "
\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - "

留言(23条)

\n" + - "\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " zp\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

能不能介绍些Movable Type的文章,我比较喜欢它的静态页面,国内关于它的资料好像还不多。特别是MT5出来后,多页面功能可能会让刚接触的人晕头转向。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 火点\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

很好,谢谢作者,只是赶到花了大量的时间在新闻上似乎有点不利于思考。

\n" + - "\n" + - "

用一个图书管理软件(BLM)整理了大学期间看过的书,仅有180本左右,汗颜,这就是我的大学……

\n" + - "\n" + - "

现在参加工作了,好在业余时间还算充裕,希望可以多读一些书。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " AlbertDiao\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

如果是手机RSS的话,摘要Feed比较好。一般浏览摘要,感兴趣的点进全文,这样比较节省流量。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 野草博客\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

嗯,野草一直在用他:)

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " Ruan YiFeng\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
引用AlbertDiao的发言:
\n" + - "\n" + - "

如果是手机RSS的话,摘要Feed比较好。一般浏览摘要,感兴趣的点进全文,这样比较节省流量。

\n" + - "\n" + - "
\n" + - "\n" + - "

流量会越来越便宜,真正昂贵的是你的时间。所以还是全文Feed好。

\n" + - "\n" + - "
\n" + - "
引用zp的发言:
\n" + - "\n" + - "

能不能介绍些Movable Type的文章。

\n" + - "\n" + - "
\n" + - "\n" + - "

我有这个打算,但是文章不太好写,还需要准备。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " luops\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

昨晚测试了此订阅
\n" + - " 同时我也保留了原订阅。
\n" + - "今天发现,同样订阅了163新闻的情况下
\n" + - "全文订阅比官方订阅少了很多新闻
\n" + - "不知其他童靴有没有这样子情况

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 鲜为人志\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

呵呵~ 这样都可以啊~

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " roy_hu\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
引用AlbertDiao的发言:
\n" + - "\n" + - "

如果是手机RSS的话,摘要Feed比较好。一般浏览摘要,感兴趣的点进全文,这样比较节省流量。

\n" + - "\n" + - "
\n" + - "\n" + - "

我更喜欢全文博客,因为在手机上看Google Reader,自动都排好了版,而看全文的时候需要浏览器排版,没有Google Reader那样专门设计给手机的看着舒服。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " Jack\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

另外,也可以用YAHOO PIPE 和YQL来抓取全文。这样除了可以把非全文的FEED变成全文输出外,还可以处理根本没有FEED输出的网页。(不过有很多网页需要处理一下GB2312和UNICODE转换。).而且这样还有一个最大的好处,就是不用建立自己的服务器。

\n" + - "\n" + - "


\n" + - "下面两个FEED 就是用这种办法生成的。
\n" + - "http://feeds.feedburner.com/wenxuecity_news

\n" + - "\n" + - "

http://feeds.feedburner.com/boxun_headline

\n" + - "\n" + - "

可以用GOOGLE READER 来读取它们。也不失为一种间接翻越G/F/W 的办法。
\n" + - "

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " Ruan YiFeng\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
引用luops的发言:
\n" + - "\n" + - "

全文订阅比官方订阅少了很多新闻

\n" + - "\n" + - "
\n" + - "\n" + - "

全文Feed默认只有4个条目,下载代码后,你可以自己修改这个值。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 坏坏鼠\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

不懂编程只会用GR的文科生飘过~~~
\n" + - "ps:阮老师的这篇文章GR里也只是显示标题,所以漂洋过海地过来了(牛博编辑的那个频道,已经将你的博客订阅了呵O(∩_∩)O)~~

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 111\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
引用luops的发言:
\n" + - "\n" + - "

全文订阅比官方订阅少了很多新闻

\n" + - "\n" + - "
\n" + - "\n" + - "


\n" + - "是这样的,丢失了好多,时效性好差
\n" + - "

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " kuber\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

想请教一下你怎么修改规则来全文输出新浪网rss的, 我也碰到几个Feed,缺省的配置不能正确处理.
\n" + - "另外我建议设立一个地方大家可以交流一下脚本不能处理的feed,以及修改的方法, 这样各人不用重复浪费时间了.

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 111\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

下载了lz的代码,发布到网站上,功能可用了。rss数量自己设置就好。

\n" + - "\n" + - "

杯具的是网站只有内网地址,gr不认生成的feed地址。

\n" + - "\n" + - "

只能CS订阅,不喜。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " lietlie\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

http://mrss.dokoda.jp/
\n" + - "虽然是小鬼子的网站,但是是我找到的能够全文Feed最好的在线工具了,和LZ推荐的网站相比,可以输出所有项目,而没有4条目的限制,当然也不必自己搭建服务器,日文内容很简单,如果使用的是FF或Chrome浏览器还可以利用Google的自动翻译功能将大致内容翻译为中文(FF利用Google Toolbar)——其实即使不翻译一样很容易使用。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " Ruan YiFeng\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
引用kuber的发言:
\n" + - "\n" + - "

想请教一下你怎么修改规则来全文输出新浪网rss的, 我也碰到几个Feed,缺省的配置不能正确处理.

\n" + - "\n" + - "
\n" + - "\n" + - "

新浪的内容容器,有一个比较怪的ID名。只要搜索这个字符串,就能提取内容了。

\n" + - "\n" + - "

最终,你还是需要读readability.php的代码,只要读懂了,我觉得任何页面都能提取。
\n" + - "

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 诗沐\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

哇 源码写得相当清爽啊~注释习惯很棒

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " xangd\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

有人在appspot上部署了一个python的port
\n" + - "http://andrewtrusty.appspot.com/readability/
\n" + - "这个没有4篇post的限制

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " neotrue\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

很好用,谢谢!

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " harvey\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

博主,作者把1.5版本放出来了,
\n" + - "可否再麻烦你打包一下,我bazzar一直不成功

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " Ruan YiFeng\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
引用harvey的发言:
\n" + - "\n" + - "

博主,作者把1.5版本放出来了,
\n" + - "可否再麻烦你打包一下,我bazzar一直不成功

\n" + - "\n" + - "
\n" + - "\n" + - "

已经加上去了,:-)

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " 张治国\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

博主,全文Feed默认只有4个条目,下载代码后,修改哪段代码可以改变这个值啊,config-sample.PHP中的数值吗?我是新手,希望博主指点一下,谢谢。

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - " felix\n" + - "\n" + - " 说:\n" + - " \n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - "

看不懂readability,不知道博主能否提供一下过滤页面上的干扰字符的方法
\n" + - "

\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - " \n" + - " \n" + - "\n" + - "\n" + - " \n" + - " \n" + - "
\n" + - "

我要发表看法

\n" + - "
\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "

\n" + - "

\n" + - "
\n" + - "
\n" + - "

\n" + - "

«-必填

\n" + - "
\n" + - "
\n" + - "

\n" + - "

«-必填,不公开

\n" + - "
\n" + - "
\n" + - "

\n" + - "

«-我信任你,不会填写广告链接

\n" + - "
\n" + - "
\n" + - "

\n" + - "

\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "

正在发表您的评论,请稍候

\n" + - "

\n" + - " \n" + - "\n" + - "

\n" + - "
\n" + - "\n" + - "

«- 点击按钮

\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "

联系方式 | ruanyifeng.com 2003 - 2012\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "

\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
分享按钮 \n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - ""; - Html html = new Html(text); - Selectable sc = html.sc(); - System.out.println(sc); - } - - @Test - public void test2(){ - String text = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " 地球上最后的夜晚 (豆瓣)\n" + - " \n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - "\n" + - " \n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - " 提醒\n" + - " \n" + - "
\n" + - "
\n" + - "

加载中...

\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "
\n" + - "
    \n" + - " \n" + - " \n" + - "
  • \n" + - " 豆瓣\n" + - "
  • \n" + - " \n" + - " \n" + - "
  • \n" + - " 读书\n" + - "
  • \n" + - " \n" + - " \n" + - "
  • \n" + - " 电影\n" + - "
  • \n" + - " \n" + - " \n" + - "
  • \n" + - " 音乐\n" + - "
  • \n" + - " \n" + - " \n" + - "
  • \n" + - " 同城\n" + - "
  • \n" + - " \n" + - " \n" + - "
  • \n" + - " 小组\n" + - "
  • \n" + - " \n" + - " \n" + - "
  • \n" + - " 阅读\n" + - "
  • \n" + - " \n" + - " \n" + - "
  • \n" + - " 豆瓣FM\n" + - "
  • \n" + - " \n" + - "
  • \n" + - " 更多\n" + - "
    \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
    九点
    阿尔法城
    移动应用
    \n" + - "
    \n" + - "
  • \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - " 豆瓣读书\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - " 搜索:\n" + - " \n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - "

\n" + - " 地球上最后的夜晚\n" + - "
\n" + - "

\n" + - "\n" + - " \n" + - "
\n" + - " \n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - "\n" + - " \n" + - " \"地球上最后的夜晚\"\n" + - " \n" + - "\n" + - "
\n" + - "

\n" + - " 更新描述或封面\n" + - "

\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " 原作名: Last Evenings on Earth
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 作者: \n" + - " \n" + - " [智利] 罗贝托·波拉尼奥\n" + - "
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 译者: \n" + - " \n" + - " 赵德明\n" + - "
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " 出版社: 上海人民出版社
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " 出版年: 2013-4-1
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " 页数: 288
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " 定价: 45.00元
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " 丛书: 罗贝托·波拉尼奥作品系列
\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " ISBN: 9787208112025
\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "

\n" + - " \n" + - "\n" + - "\n" + - " \n" + - " 8.4\n" + - " \n" + - "\n" + - " \n" + - "

\n" + - "

\n" + - " (\n" + - " \n" + - " 11人评价\n" + - " \n" + - " )\n" + - "

\n" + - " \n" + - " \n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - " 45.5%
\n" + - " \n" + - " \n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - " 9.1%
\n" + - " \n" + - " \n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - " 18.2%
\n" + - " \n" + - " \n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - " 18.2%
\n" + - " \n" + - " \n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - " 9.1%
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - "
\n" + - " \n" + - " 想读\n" + - " \n" + - " \n" + - " 在读\n" + - " \n" + - " \n" + - " 读过\n" + - " \n" + - "
\n" + - " \n" + - "\n" + - "\n" + - " \n" + - " 评价: \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "
    \n" + - "
  • \n" + - "  写笔记\n" + - "
  • \n" + - "\n" + - "
  • \n" + - "  写书评\n" + - "
  • \n" + - "\n" + - "
  • \n" + - "\n" + - " \n" + - " \n" + - "\n" + - " \n" + - " 加入购书单\n" + - " 已在购书单\n" + - "
    \n" + - "
  • \n" + - "\n" + - "
  • \n" + - " \n" + - "\n" + - "\n" + - "
    \n" + - " \n" + - "\n" + - " \n" + - "\n" + - " \n" + - "\n" + - " 添加到豆列\n" + - "
    \n" + - "\n" + - "
  • \n" + - "\n" + - " \n" + - " \n" + - " \n" + - "
  • \n" + - " 分享到   \n" + - "
  • \n" + - " \n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "
\n" + - "\n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - " 推荐\n" + - " \n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 内容简介\n" + - "  · · · · · ·\n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 作者简介\n" + - "  · · · · · ·\n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - "
\n" + - "

罗贝托•波拉尼奥(Roberto Bolaño,1953—2003)出生于智利,父亲是卡车司机和业余拳击手,母亲在学校教授数学和统计学。1968年全家移居墨西哥。1973年波拉尼奥再次回到智利投身社会主义革命却遭到逮捕,差点被杀害。逃回墨西哥后他和好友推动了融合超现实主义、达达主义以及街头剧场的“现实以下主义”(Infrarealism)运动,意图激发拉丁美洲年轻人对生活与文学的热爱。1977年他前往欧洲,最后在西班牙波拉瓦海岸结婚定居。2003年因为肝脏功能损坏,等不到器官移植而在巴塞罗那去世,年仅五十岁。

波拉尼奥四十岁才开始写小说,作品数量却十分惊人,身后留下十部小说、四部短篇小说集以及三部诗集。1998年出版的《荒野侦探》在拉美文坛引起的轰动,不亚于三十年前《百年孤独》出版时的盛况。而其身后出版的《2666》更是引发欧美舆论压倒性好评,均致以...

(展开全部)

\n" + - "\n" + - "
\n" + - " \n" + - " \n" + - "
\n" + - "

罗贝托•波拉尼奥(Roberto Bolaño,1953—2003)出生于智利,父亲是卡车司机和业余拳击手,母亲在学校教授数学和统计学。1968年全家移居墨西哥。1973年波拉尼奥再次回到智利投身社会主义革命却遭到逮捕,差点被杀害。逃回墨西哥后他和好友推动了融合超现实主义、达达主义以及街头剧场的“现实以下主义”(Infrarealism)运动,意图激发拉丁美洲年轻人对生活与文学的热爱。1977年他前往欧洲,最后在西班牙波拉瓦海岸结婚定居。2003年因为肝脏功能损坏,等不到器官移植而在巴塞罗那去世,年仅五十岁。

波拉尼奥四十岁才开始写小说,作品数量却十分惊人,身后留下十部小说、四部短篇小说集以及三部诗集。1998年出版的《荒野侦探》在拉美文坛引起的轰动,不亚于三十年前《百年孤独》出版时的盛况。而其身后出版的《2666》更是引发欧美舆论压倒性好评,均致以杰作、伟大、里程碑、天才等等赞誉。苏珊•桑塔格、约翰•班维尔、科尔姆•托宾、斯蒂芬•金等众多作家对波拉尼奥赞赏有加,更有评论认为此书的出版自此将作者带至塞万提斯,斯特恩,梅尔维尔,普鲁斯特,穆齐尔与品钦的同一队列。

\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 目录\n" + - "  · · · · · ·\n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " 圣西尼……………………………………3
\n" + - " 亨利·西蒙·勒普兰斯…………………… 27
\n" + - " 恩里克·马丁……………………………39
\n" + - " 一件文学奇事…………………… ……59
\n" + - " 通话…………………… ………………75
\n" + - " 毛毛虫…………………………………83
\n" + - " · · · · · ·\n" + - " (更多)\n" + - "
\n" + - "\n" + - "
\n" + - " 圣西尼……………………………………3
\n" + - " 亨利·西蒙·勒普兰斯…………………… 27
\n" + - " 恩里克·马丁……………………………39
\n" + - " 一件文学奇事…………………… ……59
\n" + - " 通话…………………… ………………75
\n" + - " 毛毛虫…………………………………83
\n" + - " 安妮·穆尔的生平 ……………………101
\n" + - " “小眼”席尔瓦 ………………………139
\n" + - " 戈麦斯帕拉西奥 ……………………159
\n" + - " 地球上最后的夜晚………………… 173
\n" + - " 1978 年的几天………………………205
\n" + - " 在法国和比利时闲逛…………………225
\n" + - " 牙科医生…………………… ………245
\n" + - " 邀舞卡……………………………… 273
\n" + - " · · · · · · (收起)\n" + - "
\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " "地球上最后的夜晚"试读\n" + - "  · · · · · ·\n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "
\n" + - "

情况是这样的:B 和B 父去阿卡普尔科度假。一大早,清晨六点,父子俩就要出发。那天夜里,B 睡在父亲家里。没梦,或者就算有梦,一睁眼也忘了。听见父亲在卫生间。向窗外望去,一片漆黑。B 不开灯,穿衣裳。等走出卧室的时候,父亲已经在桌旁看前一天的体育报纸了。早饭已经做好了。咖啡,牧场煎蛋。B 问候父亲后,走进卫生间。\n" + - "B 父的汽车是1970 年的福特野马。六点半,父子俩上车,开..

\n" + - "\n" + - "
· · · · · · (查看全部试读)
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 豆瓣成员常用的标签(共38个)\n" + - "  · · · · · ·\n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "
罗贝托-波拉尼奥(68)   拉美文学(35)   外国文学(24)   小说(22)   智利文学(14)   波拉尼奥(10)   智利(10)   小说集(10)  
\n" + - "
\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "
\n" + - "

丛书信息

\n" + - "
\n" + - "  罗贝托·波拉尼奥作品系列 (共6册),\n" + - "这套丛书还有\n" + - "《2666》,《荒野侦探》,《2666》,《荒野侦探》,《护身符》。
\n" + - "
\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "

\n" + - " 书评  · · · · · · \n" + - "

\n" + - " \n" + - " 我来评论这本书\n" + - "\n" + - "\n" + - " \n" + - "\n" + - " \n" + - "\n" + - "
\n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \"DeadKennedy\"/\n" + - "\n" + - "
\n" + - "

\n" + - "
\n" + - " \">\"\n" + - " \n" + - " \"<\"\n" + - "
\n" + - " 信仰的挽歌\n" + - "

\n" + - "
\n" + - " \n" + - " DeadKennedy   \n" + - " \n" + - " \n" + - "

\n" + - "
\n" + - " Elegy to Faith\n" + - "\n" + - "\n" + - "波拉诺难得的短篇集。\n" + - "\n" + - "\n" + - "比之长篇,波拉诺的短篇是其能力的代表。他的长篇像话剧台词,冗长,精彩,让人迷失其中,在读过大概三百页之后似乎明白一些他在说什么。而他的短篇则像电台DJ的串词,明了,信息丰富,基本是波拉诺的自传和自白。很多篇目就是作家自身经历的镜像。是一些关于动荡,个人自由,劳动,知识份子,流放和坚持的故事。纽约时报评论这本书为“流放民谣”。\n" + - "\n" + - "\n" + - "比如写自身经历的:......\n" + - "\n" + - "

\n" + - " \n" + - " 2012-02-14 13:53    \n" + - " 2/2有用\n" + - " \n" + - " \n" + - " 来自 New Directions2007版\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - " \n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - " \"DeadKennedy\"/\n" + - "\n" + - "
\n" + - "

\n" + - "
\n" + - " \">\"\n" + - " \n" + - " \"<\"\n" + - "
\n" + - " 信仰的挽歌\n" + - "

\n" + - "
\n" + - " \n" + - " DeadKennedy   \n" + - " \n" + - " \n" + - "

\n" + - "
\n" + - " Elegy to Faith\n" + - "\n" + - "\n" + - "波拉诺难得的短篇集。\n" + - "\n" + - "\n" + - "比之长篇,波拉诺的短篇是其能力的代表。他的长篇像话剧台词,冗长,精彩,让人迷失其中,在读过大概三百页之后似乎明白一些他在说什么。而他的短篇则像电台DJ的串词,明了,信息丰富,基本是波拉诺的自传和自白。很多篇目就是作家自身经历的镜像。是一些关于动荡,个人自由,劳动,知识份子,流放和坚持的故事。纽约时报评论这本书为“流放民谣”。\n" + - "\n" + - "\n" + - "比如写自身经历的:......\n" + - "\n" + - "

\n" + - " \n" + - " 2012-02-14 13:53    \n" + - " 2/2有用\n" + - " \n" + - " \n" + - " 来自 New Directions2007版\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "
\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 论坛\n" + - "  · · · · · ·\n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
平装or精装?孔亚雷or赵德明?来自Nihilum5 回应2013-04-21
書到底出了沒啊?来自阿城199114 回应2013-04-13
不是翻译问题,是根本看不懂来自呆呆双鱼女1 回应2013-04-20
\n" + - "\n" + - "\n" + - "

>\n" + - " 在这本书的论坛里发言\n" + - "

\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "

\n" + - " 在哪儿买这本书?\n" + - "

\n" + - " \n" + - "
\n" + - " \n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 加入购书单\n" + - " \n" + - " 已在购书单 \n" + - " 查看\n" + - " 删除\n" + - " \n" + - " \n" + - " \n" + - "\n" + - " 多本比价,批量购买\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 这本书的其他版本 \n" + - "  · · · · · ·\n" + - "  (\n" + - " 全部3\n" + - " ) \n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - "
\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 以下豆列推荐\n" + - "  · · · · · ·\n" + - "  (\n" + - " 全部\n" + - " ) \n" + - "\n" + - "

\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - "
\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "

谁读这本书?

\n" + - "
\n" + - "\n" + - " \n" + - "\n" + - " \n" + - "
\"小K\"
\n" + - "
小K
\n" + - "
13分钟前 想读
\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "

\n" + - "
\n" + - " \n" + - "
\"杰森辛普森\"
\n" + - "
杰森辛普森
\n" + - "
28分钟前 想读
\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "

\n" + - "
\n" + - " \n" + - "
\"Aby\"
\n" + - "
Aby
\n" + - "
37分钟前 想读
\n" + - "\n" + - "
\n" + - "\n" + - " tags:对人生的诠释\n" + - "\n" + - "
\n" + - "

\n" + - "
\n" + - " \n" + - "
\"老男孩\"
\n" + - "
老男孩
\n" + - "
1小时前 想读
\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "

\n" + - "
\n" + - "\n" + - "\n" + - "

> 5人在读

\n" + - "

> 12人读过

\n" + - "

> 658人想读

\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - " \n" + - " \n" + - "\n" + - "

\n" + - "\n" + - " 喜欢这本书的人常去的小组\n" + - "  · · · · · ·\n" + - "\n" + - "

\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - " \n" + - "
\n" + - "
\"托马斯·品钦\"/
\n" + - " \n" + - "
托马斯·品钦 (711)\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\"短经典\"/
\n" + - " \n" + - "
短经典 (787)\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\"寻找:布鲁诺.舒尔茨\"/
\n" + - " \n" + - "
寻找:布鲁诺.舒尔茨 (466)\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\"胡安·鲁尔福\"/
\n" + - " \n" + - "
胡安·鲁尔福 (613)\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\"V.S.奈保尔\"/
\n" + - " \n" + - "
V.S.奈保尔 (445)\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\"胡利奥·科塔萨尔\"/
\n" + - " \n" + - "
胡利奥·科塔萨尔 (1053)\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\"中国当代书籍装帧摭评\"/
\n" + - " \n" + - "
中国当代书籍装帧摭评 (1373)\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\"泼先生\"/
\n" + - " \n" + - "
泼先生 (485)\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "
\n" + - "

> 收藏这本书的1个小组

\n" + - "
\n" + - "

> \n" + - " 加到我的小组收藏里 \n" + - "

\n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "

二手市场

\n" + - "
\n" + - "
    \n" + - "
  • \n" + - " > 点这儿转让\n" + - "\n" + - " 有658人想读,手里有一本闲着?\n" + - "
  • \n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - "

订阅关于地球上最后的夜晚的评论:
\n" + - " feed: rss 2.0

\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - "
\n" + - "\n" + - "\n" + - "\n" + - " © 2005-2013 douban.com, all rights reserved\n" + - "\n" + - "\n" + - "\n" + - " 关于豆瓣\n" + - " · 在豆瓣工作\n" + - " · 联系我们\n" + - " · 免责声明\n" + - " \n" + - " · 帮助中心\n" + - " · 开发者\n" + - " · 图书馆合作\n" + - " · 手机读书\n" + - " · 豆瓣广告\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n"; - - Html html = new Html(text); - System.out.println(html.sc()); - - } -} diff --git a/webmagic-core/src/test/java/us/codecraft/webmagic/selector/XpathSelectorTest.java b/webmagic-core/src/test/java/us/codecraft/webmagic/selector/XpathSelectorTest.java index 96ea6e8c..469ff26c 100644 --- a/webmagic-core/src/test/java/us/codecraft/webmagic/selector/XpathSelectorTest.java +++ b/webmagic-core/src/test/java/us/codecraft/webmagic/selector/XpathSelectorTest.java @@ -4,2747 +4,1353 @@ import org.junit.Assert; import org.junit.Test; /** - * User: cairne - * Date: 13-4-21 - * Time: 上午10:06 + * User: cairne Date: 13-4-21 Time: 上午10:06 */ public class XpathSelectorTest { - String huxiuHtml = "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "产品情感化设计的两个层面-观点-@虎嗅网\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\t\t\t\n" + - "\t\n" + - "
\n" + - "

\"虎嗅网\"

\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "订阅虎嗅\n" + - "RSS\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - "
\n" + - " \n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "\n" + - "

产品情感化设计的两个层面

\n" + - "\n" + - "
\n" + - "
\n" + - " 2013-4-22 16:10\n" + - " \n" + - " \t评论(0)\n" + - " \n" + - "产品\n" + - "投稿\n" + - "\n" + - "
\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - "
\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
\n" + - " \"\"\n" + - " 用户之所以选择一款产品,首要的一点在于产品的功能或内容满足了用户。而随着产品的发展,同类型的产品基础功能都大致相同,产品之间的竞争越来越难在功能层面拉开差距。现在产品人员也更加开始在用户体验上下功夫了,而对用户体验的不断追求也就上升到了情感层面。

谈起产品情感化设计,可以拿手机通讯录中添加联系人头像来举例子,单就这个功能点而言,最基础的只要用户能够添加联系人的头像即可,而如果在这个功能上添加用户情感化的元素后,就可以在用户的头像展示上给予更大空间,让用户能够更大的发挥自己的个性。我们也发现新浪微博和开心网个人主页的设计也都增加了个人封面的展示。产品情感化对于功能本身是没有影响的,而情感因素后,产品对用户还会更有吸引力。短期来看,个性化和给用户更大的发挥空间是产品情感化设计的两个很重要的方向。

产品的情感化设计有两个不同的做法:一个是在已有功能上进行扩展,如上文所提到的通讯录中上传头像的功能,是对用户表达欲的满足,用户情感的单向表达;另一种做法则是做一个完全情感化的产品,用户情感的双向表达,是用户之间情感内容的交流,产品扮演的只是桥梁作用,例如小恩爱、抬杠这样的产品。其实所有涉及到用户互动性的产品对于情感化的拓展空间都很大,但是与普通社交不同的是,产品的情感化在于人与人之间更深层次的交流。在我个人看来,社交网站中的发状态功能已经仅仅是用户表达的工具,极少含有感情因素,但是像Facebook推出的暗恋功能却是一个情感化产品,产品的情感化不仅在于让用户将自己的情感寄予到产品中,而且产品要想具有情感化很重要的一点在于产品本身能够起到挖掘用户情感的作用。

前面所提到的两种做法区别在于,前者是基于已有需求而进行的情感化设计,而后者则是完全情感化的产品,就成功率来讲,显然是前者更大一些。本身有需求的产品对于产品的情感化发展不仅奠定了基础,而且也烘托了氛围,做好了铺垫。如果是做一个完全情感化的产品,失败的可能性很大。当产品的功能满足了用户的情感表达,那就意味着产品可以满足用户的需求,而当产品本身所扮演的角色无法成为用户的寄托,那么产品就会面临失败。可想而知,情感化的产品肯定属于UGC类型,对于用户内容的质量要求会比较高,当技术水平不够高、功能操作不够便捷的时候,自然就提高了使用门槛。而且这种类型的产品对于氛围的烘托本身就会有相对高的要求。

如果单从功能角度去衡量,用户情感的单向表达属于功能层面,而用户情感的双向表达属于内容层面。除此之外,产品情感化还有文案和产品风格上的表现。

你是一个资深网虫,或许你也有所感觉,现在的网站文案已经越来越有人情味了。例如提示文案不是“你的账号密码错误”而是“密码不对哦”,文案中增加了语气词。这只是其中的一种表达方式,除此之外,你会看到产品设计中的很多引导方式也更有趣味性,文案内容的情感化也会增加用户的接受程度。

最近自己在使用产品中也有个很大的感触,就是产品风格对用户的吸引,同样是天气类应用,功能上相差无几,但是不同的风格却可以吸引不同的受众。有的是大众普通的风格,有的是小清新风格,有的是卡通风格等等,可以理解为用户对不同风格产品的选择背后的原因就是用户个人情感的不同,而用户的这种情感不能改变只能顺从。

更深层次的讲,产品情感化的关键在于产品功能与用户情感的承接,满足人们情感的诉求。从心理学上讲人的本性有很多,例如表达欲、攀比心理,但从人的本性和产品的情感化进行匹配,会有太多的点,在这里就不一一例举了,大家可以在产品的使用过程中逐渐感受。而之所以要选择利用人性情感的哪一点来设计产品就要根据具体的产品目标来衡量了。

文章来源:马虎眼    作者微信账号:mahuyan


本文由\n" + - "云瑞\n" + - "授权虎嗅网发表,并经虎嗅网编辑。转载此文章须经作者同意,并请附上出处(虎嗅网)及本页链接。
原文链接http://www.huxiu.com/article/13380/1.html\n" + - "
\n" + - "
\n" + - " \n" + - " \n" + - "
\n" + - " \n" + - "\n" + - " \n" + - "\n" + - "\n" + - " \n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "
\n" + - " 分享(0):\n" + - "
\n" + - "
\n" + - "
    \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - "
  • \n" + - " \n" + - "
  • \n" + - "
\n" + - " \n" + - "
\n" + - "
收藏\n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - " 没劲 \n" + - " 喜欢 \n" + - "
\t\t \n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "

参与讨论,请先登录|注册

\n" + - "

\n" + - "\n" + - "\n" + - "

\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - " \n" + - " \n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "\t\t\t
\n" + - "

作者:云瑞

\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "
\n" + - "
个人签名
\n" + - "
人人都爱互联网
\n" + - "
\n" + - "
\n" + - "\t\t\t\t\n" + - "

作者其他文章

\n" + - "\n" + - " \n" + - "更多文章\n" + - "
\n" + - "\n" + - "
\n" + - "

您不能错过的作者

\n" + - "
  • \n" + - "

    \"葛甲\"

    \n" + - "

    葛甲

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"吴澍\"

    \n" + - "

    吴澍

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"知乎精选\"

    \n" + - "

    知乎精选

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"译言\"

    \n" + - "

    译言

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"潘乱\"

    \n" + - "

    潘乱

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"王云辉\"

    \n" + - "

    王云辉

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"阑夕\"

    \n" + - "

    阑夕

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"胡晓东\"

    \n" + - "

    胡晓东

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"阳淼\"

    \n" + - "

    阳淼

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"魏武挥\"

    \n" + - "

    魏武挥

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"高低买个皮夹克\"

    \n" + - "

    高低买个皮夹克

    \n" + - "
  • \n" + - "
  • \n" + - "

    \"潘越飞\"

    \n" + - "

    潘越飞

    \n" + - "
  • \n" + - "\t\n" + - "
\n" + - "
\n" + - "\n" + - " \t\t\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "\n" + - "
\n" + - "\n" + - "
\n" + - " \n" + - "
\n" + - " \n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\t
\n" + - "\n" + - "\n" + - "
\n" + - "
\n" + - "

关于我们|加入我们|广告及服务|常见问题解答|提交建议\n" + - "\n" + - "

\n" + - "

Copyright © 虎嗅网\n" + - "( 京ICP备12013432 )

\n" + - "
\n" + - "
\n" + - "\n" + - " 
\n" + - "\n" + - "回顶部\n" + - "\n" + - "\t\t\t
\n" + - "\t\t\t\n" + - "\t\t\t\n" + - "\n"; - - String blogHtml = "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 一个基于Python装饰器的用户输入验证设计方案 - SamChi的个人空间 - 开源中国社区\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "\n" + - "
\n" + - "\t
\n" + - "\t\t
\n" + - " \t开源中国社区\n" + - "
\n" + - " \t\t
JetBrains 开发工具全场3折,详情»
\n" + - "
\n" + - " \t\n" + - "
\n" + - "
\n" + - "\t
\n" + - "\t
\n" + - "\t\t
\n" + - "\t\t当前访客身份:\n" + - "\t\t\t\t黄亿华 [ 我的空间 | 退出 ]\n" + - "\t\t\t\t\t\t\t\n" + - "\t\t\t\t\t\t你有0新留言\t\t\t\n" + - "\t\t\t\t\t\t\t\t\n" + - "\t\t
\n" + - "\t\t
\n" + - " \t\t
\n" + - "\t\t\t\t\n" + - "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n" + - " \t\t\t\n" + - "\t\t\t\t\n" + - "\t\t\t\t
\n" + - " \t\t\t\t\n" + - " \t\t\t\t\n" + - " \t\t\t\t\n" + - "
软件
\n" + - " \n" + - "
\n" + - "\t\t\t\t\t\t\t\n" + - " \t\t
\n" + - "\t\t
\n" + - "\t\t
\n" + - "\t
\n" + - "\t
\t\n" + - "\n" + - "
\n" + - "
\n" + - "\t \"SamChi\"\n" + - " \n" + - " SamChi\n" + - "\t\t\n" + - "\t\t\t\n" + - " \t\t\t\t\t\t\t\n" + - " \n" + - "
\n" + - "
\n" + - " \t关注(21)\n" + - " \t粉丝(52)\n" + - " \t积分(37)\n" + - "
\n" + - "
\n" + - "
\n" + - "这个人很懒,啥也没写
\n" + - "\n" + - "
\n" + - "\t.发送留言\n" + - "\t.请教问题\n" + - "
\n" + - " 博客分类\n" + - " \n" + - "
\n" + - "
\n" + - " 最新评论 \n" + - "
    \n" + - "\t\t
  • \n" + - "\t\t@其斤君羊:说的很对 做什么事情都得从身边做起 更何况创业 ...\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@techstan:不错\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@摩云飞:谢谢博主的总结,很有价值\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@尚楠:正在学Python,谢了\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@knightuniverse:其实我觉得,很多时候,不论是做项目还是做产品,...\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@moyun:顶一个\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@SamChi:引用来自“Martinium”的评论 alert('I am admi...\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@Martinium:alert('I am admin, bitch!'); 这句话亮了。...\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@Ben:引用来自“ExtremeTalk”的评论 引用来自“Ben”...\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t\t
  • \n" + - "\t\t@ExtremeTalk:引用来自“Ben”的评论 引用来自“ExtremeTalk”...\n" + - "\t\t查看»\n" + - "\t
  • \n" + - "\t
\n" + - "
\n" + - "访客统计\n" + - "
    \n" + - "\t
  • 3
  • \n" + - "
  • 33
  • \n" + - "
  • 36
  • \n" + - "
  • 842
  • \n" + - "
  • 13706
  • \n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "
\n" + - "\t
\n" + - " \t\n" + - "\t
\n" + - "\t\n" + - " \t
\t\t\n" + - "
\n" + - "

一个基于Python装饰器的用户输入验证设计方案

\n" + - "
\n" + - " \t\t \t\t \t \n" + - "\t\t\t\t\n" + - "\n" + - "8人收藏此文章,\n" + - "\n" + - "\t\n" + - "\t\t\t\n" + - " \t\t \t\t发表于7天前(2013-04-15 16:46) , \n" + - " \t\t已有127次阅读 ,共0个评论\n" + - " \t\t \t
\n" + - "
\n" + - "\t

情景

\n" + - "

最近初学Python, 语法大概熟悉了之后就开始拿web.py做点小东西,web.py非常轻量,用起来感觉很舒服。但不过无论什么语言或者框架,web开发中有一个最大烦人之处就是表单验证,web.py提供了web.form来进行表单验证的统一处理,这个东西虽然用起来很简单,但是感觉还是不太合心意,首先这套验证机制跟web.py框架耦合的程度太高,而自己的架构是这样的,业务逻辑跟web逻辑完全分离,web仅仅是交互形式的一种,即使添加客户端C/S形式的服务或者是向开发者提供API,业务逻辑也是完全可用,不需要修改,这样对用户输入的验证是属于业务逻辑这一块,不应该跟web表单耦合在一起;另外感觉web.py这套东西还是有些简单,只支持每个表单的正则验证和最后表单提交的整体验证,而很多时候可能需要对用户进行丰富的错误提示,比如针对用户名的错误会具体到是不能为空还是长度错误或者格式错误等, 这个用web.py的form验证就感觉很别扭了。于是就决定自己设计一个用户输入的验证方案。

\n" + - "

设计

\n" + - "

web项目的开发多数都是遵循这么一个结构的设计,即DAO->Service->Controller->View, 按我前面说的,对用户的输入验证应是发生在Service这一层上,这一层的设计是接受用户输入的参数,然后进行验证处理,再进行业务相关的计算,最后输入结果。每个Service接口都应该返回一个结果,我一般都会把这个结果的内容抽象成一个一致类型的对象:

\n" + - "
class Result(object):\n" +
-            "    \n" +
-            "    u''' 操作结果抽象 '''\n" +
-            "    \n" +
-            "    def __init__(self, code, value=None):\n" +
-            "        self.code = code   #操作结果代号\n" +
-            "        self.value = value #操作结果值\n" +
-            "        \n" +
-            "    def __str__(self):\n" +
-            "        return "operation result, code: %s, value: %s" % (self.code, self.value)
\n" + - "

这个结果对象包含两个属性,一个是操作结果的代码,一个是操作的值,举个例子,比如用户注册的接口,如果注册成功,那么就会返回一个这样的Result对象,code属性是'success', value属性是新注册用户分配的ID,如果用户名已经被占用,那么code属性就是'username_exised', value属性的值是None。客户端拿到code属性的值可以做响应的处理,如果是直接面向最终用户的web应用,那么就会去找到这个code对应的错误信息来展示给用户,所有的错误信息我是组织在一个单独的Python模块中(opresult.py):

\n" + - "
reg = {\n" +
-            "       'success':u'注册成功',\n" +
-            "       'username_empty':u'用户名不得为空',\n" +
-            "       'username_format':u'用户名必须只能有数字、字母下划线组成',\n" +
-            "       'username_length':u'用户名长度必须在5到10个字符之间',\n" +
-            "       'username_existed':u'用户名已经存在',\n" +
-            "       'password_empty':u'密码不得为空',\n" +
-            "       'repassword_error':u'两次密码输入不一致',       \n" +
-            "       }
reg是注册的接口名称,这样客户端通过接口名称和code就可以获取对应的提示。 \n" + - "

由此,用户输入验证就是要把接口参数同这些code联系起来。对于参数验证,Python有天生的语言优势,那就是装饰器。一开始就想到了使用装饰器来描述参数验证需求,但这个装饰器需要哪些信息?怎么个形式?这个得从表单验证的需求开始看起,个人总结表单验证大抵不过这些判断条件:

\n" + - "

1. 是否允许为空

\n" + - "

2. 长度限制:比如密码的长度一般会不允许少于多少位

\n" + - "

3. 格式限制:比如Email地址,需要正则判断

\n" + - "

4. 逻辑限制:比如注册时判断用户名是否已经存在

\n" + - "

初步根据这些判断条件设计出这么一个方案:

\n" + - "
@checkarg(username={'allow_empty':False, \n" +
-            "                    'regex':r'^[a-zA-Z\\d_]+$',\n" +
-            "                    'min-length':5, 'max-length':10, \n" +
-            "                    'check_logic':[check_username_usable]},\n" +
-            "          password={'allow_empty':False,'regex':r'.{6,}'},\n" +
-            "          repassword={'allow-empty':False, 'check_logic':\n" +
-            "                      [(lambda **kw:(kw['password'] == kw['repassword'], "repassword_error"))]})\n" +
-            "def reg(username, password, repassword):\n" +
-            "    ....
\n" + - "

每一个参数使用一个字典来描述验证信息, allow_empty是表示是否为空,regex为验证的正则表达式,min-length和max-length用来描述长度,check_logic用来配置其他的验证逻辑。然后如何把这些验证结果同code进行匹配呢?最开始是在这个验证信息的字典中有一项'code':{'allow_empty':'username_empty'}通过这样的形式去匹配错误提示,但是感觉这样整的这个参数太复杂了(感觉现在已经挺复杂了- -b),于是决定这个地方使用约定优于配置的形式,code的值为'参数名_错误类型'的形式,比如allow_empty如果验证了为空,那么会自动返回名为username_empty的code,如果是一些额外的处理逻辑呢?没法做约定,怎么办?那么就约定这些检测函数返回一个元组,第一个元素为一个bool值,表示成功失败,第二个参数为code,表示失败原因,比如判断两次密码是否输入一致的那个lambda:

\n" + - "
lambda **kw:(kw['password'] == kw['repassword'], "repassword_error"
\n" + - "

嗯,大体就是这样的一个设计。

\n" + - "

实现

\n" + - "

根据上面的设计,把最终的装饰器实现了出来, 逻辑比较简单,关于装饰器设计的一些细节可以参阅Python参考手册:

\n" + - "
regex_cache = {}\n" +
-            "     \n" +
-            "def checkarg(**args):\n" +
-            "    \n" +
-            "    u'''参数检测装饰器'''\n" +
-            "    \n" +
-            "    def _checkarg(function):\n" +
-            "        \n" +
-            "        def __checkarg(**func_kw):\n" +
-            "            for key in func_kw:\n" +
-            "                if key in args:\n" +
-            "                    \n" +
-            "                    #要验证的值\n" +
-            "                    value = func_kw[key]\n" +
-            "                    \n" +
-            "                    #验证规则\n" +
-            "                    valid_rules = args[key]\n" +
-            "                    \n" +
-            "                    #检测空\n" +
-            "                    allow_empty = valid_rules.get('allow_empty')\n" +
-            "                    if not allow_empty:\n" +
-            "                        if not value or not value.strip():\n" +
-            "                            return Result(key + "_empty")\n" +
-            "                    elif not value:\n" +
-            "                        #如果是空的并且忽略空检测,那么下面的就不需要检查了\n" +
-            "                        continue;\n" +
-            "                    \n" +
-            "                    #检测长度\n" +
-            "                    if 'min-length' in valid_rules:\n" +
-            "                        min_length = valid_rules['min-length']\n" +
-            "                        if min_length > len(value):\n" +
-            "                            return Result(key + "_length")\n" +
-            "                        \n" +
-            "                    if 'max-length' in valid_rules:\n" +
-            "                        max_length = valid_rules['max-length']\n" +
-            "                        if max_length < len(value):\n" +
-            "                            return Result(key + "_length")\n" +
-            "                    \n" +
-            "                    #检测正则\n" +
-            "                    if 'regex' in valid_rules:\n" +
-            "                        #获取编译后的正则\n" +
-            "                        regex = valid_rules['regex']\n" +
-            "                        regexcmp = regex_cache.get(regex)\n" +
-            "                        if not regexcmp:\n" +
-            "                            regexcmp = re.compile(regex)\n" +
-            "                            regex_cache[regex] = regexcmp\n" +
-            "                        if not regexcmp.search(value):\n" +
-            "                            return Result(key + "_format")\n" +
-            "                    \n" +
-            "                    #检测其他逻辑\n" +
-            "                    check_logics = valid_rules.get('check_logic')\n" +
-            "                    if check_logics:\n" +
-            "                        for logic in check_logics:\n" +
-            "                            result, code = logic(**func_kw)\n" +
-            "                            if not result:\n" +
-            "                                return Result(code)\n" +
-            "                                \n" +
-            "            function(**func_kw)\n" +
-            "        return __checkarg\n" +
-            "                            \n" +
-            "    return _checkarg
\n" + - "\t \t \n" + - "
\n" + - "\t\t\n" + - "
\n" + - "\t \t\n" + - "\t \t \n" + - "
\t\t\n" + - "\t \t\t声明:OSCHINA 博客文章版权属于作者,受法律保护。未经作者同意不得转载。\n" + - "\t \t
\n" + - "\n" + - " \n" + - "\t
\n" + - "\n" + - "\t\n" + - "\t
\n" + - "\t\n" + - "\t\n" + - "\t\t分享到: \n" + - "\t\t\n" + - "\t\t\n" + - "\t\n" + - " 已有 0人顶\n" + - "\t\n" + - "\t
\n" + - "\t\t\n" + - "
\n" + - "
\n" + - "
\n" + - "

共有 0 条网友评论

\n" + - "\t\t\t

尚无网友评论

\n" + - "\t\t
    \n" + - "\t\t
\n" + - "
\n" + - "\t
\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - " \n" + - "
\n" + - "
\n" + - "
\n" + - "\t \n" + - "\t \n" + - "\t 文明上网,理性发言\n" + - "
\n" + - "\t回到页首 | 回到评论列表\n" + - "
\n" + - "
\n" + - "\t\n" + - "
\n" + - "\t关闭相关文章阅读\n" + - "\t\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\t
\n" + - "\t
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
© 开源中国(OsChina.NET) | 关于我们 | 广告联系 | @新浪微博 | 开源中国手机版 | 粤ICP备12009483号-3\n" + - "\t开源中国手机客户端:\n" + - "\tAndroid\n" + - "\tiPhone\n" + - "\tWP7\n" + - "
\n" + - "
\n" + - "
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - ""; - - String html = "\n" + - "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " 再次吐槽easyui - 开源中国 OSChina.NET\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - "
\n" + - "\t
\n" + - "
\n" + - " \t\n" + - "
\n" + - "\t\t
\n" + - " \t\t \t\t黄亿华,您好 \n" + - "\t\t\t\n" + - "\t\t\t\t我的空间\n" + - "\t\t\t\t\n" + - "\t\t\t | \n" + - "\t\t\t添加软件 | 投递新闻 | 退出\n" + - " \t\t\t\t
\n" + - "\t\t
\n" + - "\t
\n" + - "
\n" + - "
\n" + - "

讨论区

\n" + - "
\n" + - "\t
当前位置:
\n" + - "\t
\n" + - "\t\t\t\t\t \t\t讨论区 »\n" + - " \t\t技术问答\t\t\t\t\t\t\t\t» EasyUI\n" + - "\t\t\t\t\t\t\t\t\t\t
\n" + - "
\n" + - "\n" + - "
\n" + - "
\n" + - "\t
\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
\n" + - "\t\n" + - "\t
\n" + - "\t
\n" + - "\t\t
\"午后冬日\"
\n" + - "\t\t
\n" + - "\t\t\t

再次吐槽easyui

\n" + - "\t\t\t
\n" + - "\t\t\t\t午后冬日\n" + - "\t\t\t\t发表于 2013-4-21 02:28 13小时前,\n" + - "\t\t\t\t3回/289阅,\n" + - "\t\t\t\t最后回答: 4小时前\t\t\t\t\t\t\t\t\t\t\t
\n" + - "\t\t
\n" + - "\t\t\n" + - "\t\t
\n" + - "\t
\n" + - "\t\t \t \t\t\t\t\t\n" + - "\t\t

Java、PHP、Ruby、iOS、Python 等 JetBrains 开发工具低至 99 元(3折),详情»

\n" + - "\t\t
\n" + - "\t\t\t\t\t\t
刚用到easyui treegrid组件,发现这货第一次加载时候并没有传默认参数,展开某一列时候才传递id:xx的参数。这样和后台总是疙里疙瘩,像没事就拌嘴的两口子,查网上都遇到相同问题,最好解决方案就是通过 \n" + - "onBeforeExpand事件来扩展,自行解决。看到官方例子中简洁的代码,感觉easyui耍流氓了,真搞不懂为何要这样实现
\n" + - "\t\t\t\t\t\t
\n" + - "\t\t\t\t标签:\t\t\t\t\n" + - "\t\t\t\t\t\t\t\t\t\t\t\tEasyUI \t\t\t\t\t\t\t\t\t\t\t
\n" + - "\t\t\t\t\t\t
\n" + - "\t\t\t\n" + - "\t\t\t\t\t\t\t\t\t我想问同样的问题\n" + - "\t\t\t\t\t\t\n" + - "\t\t\t共0个人想要问同样的问题\n" + - "\t\t\t\t\t\t补充话题说明»\n" + - "\t\t\t
\n" + - "\t\t\t\t\t\t
\n" + - "\t
    \n" + - "
    \t\t
    \n" + - "\t\t\n" + - "\t\t
    \n" + - " \n" + - "\t\t\t\t
    \n" + - "\t\t\t
    分享到
    \n" + - "\t\t\t\n" + - "\t\t\t
    1
    \n" + - "\t\t\t\n" + - "\t\t\t
    \n" + - "\t\t\t\t\t\t\t\t \t\t\t\n" + - "\t\t\t\t\t\t\t\t0\n" + - "\t\t\t\t|\n" + - "\t\t\t\t\t\t\t\t \t\t\t\n" + - "\t\t\t\t\t\t\t\t0\n" + - "\t\t\t
    \n" + - "\t\t\t\n" + - "\t\t
    \n" + - "\t\t
    \n" + - "\t\t\t\t\t\t
    \n" + - "\t\t\t\n" + - " \t

    \t\t\t\n" + - "\t\t\t\t\n" + - "\t\t\t\t\t按评价排序 |\n" + - "\t\t\t\t\t显示最新答案 | 回页面顶部\n" + - "\t\t\t\t\n" + - "\t\t\t\t共有3个答案 我要回答»\n" + - "\t\t\t

    \n" + - "\t\t\t \t
    • \n" + - "\t
      \"布谷鸟\"
      \n" + - "\t
      \n" + - "\t\t
      布谷鸟 回答于 2013-04-21 09:28
      \t\t\n" + - " \t
      \n" + - "\t\t\t \t\t \t\t举报\n" + - " \t
      \n" + - "\t\t
      \n" + - "\t\t
      对话框、日期控件和选项卡效果还不错,树状菜单没得zTree好用,建议楼主不要全部效果都依赖于此框架,有些easyui实现不好的地方可以换其它的插件实现嘛,反正我现在再也不用诸如ext和easyui之类的东西了,感觉好肥
      \n" + - "\t
      \n" + - "\t
      \n" + - "\t
      --- 共有 1 条评论 --- \n" + - "
        \n" + - "\t\t
      • \n" + - "\t\t\"午后冬日\"\n" + - "\t\t\n" + - "\t\t前端水平实在有限,自己搞的总是感觉不伦不类,只能用这些框架,再集成其它插件,切换主题时风格又不一致。\n" + - "\t\t(4小时前 by 午后冬日)\n" + - "\t\t回复\n" + - "\t\t\n" + - "\t\t
        \n" + - "\t
      • \n" + - "\t
      \n" + - "\n" + - "
      \n" + - "\t
      \t\t\t\t\t\t有帮助(1) |\n" + - "\t\t没帮助(0) |\n" + - "\t\t评论(1) |\n" + - " \t引用此答案\t
      \n" + - "
    • \n" + - "\t
      \"静风流云\"
      \n" + - "\t
      \n" + - "\t\t
      静风流云 回答于 2013-04-21 11:08
      \t\t\n" + - " \t
      \n" + - "\t\t\t \t\t \t\t举报\n" + - " \t
      \n" + - "\t\t
      \n" + - "\t\t

      没办法,原来项目也是因为客户特殊的需求,对layout选型的时候,犹豫了好久,最终放弃了。
      幸亏来了一个厉害的前端,解决问题,够用就好。

      \n" + - "\t
      \n" + - "\t
      \n" + - "\t
      --- 共有 1 条评论 --- \n" + - "
        \n" + - "\t\t
      • \n" + - "\t\t\"午后冬日\"\n" + - "\t\t\n" + - "\t\t我也是犹豫了好久,看过很多前端框架,总是不太满意。个人开发前台后台数据库全部要自己搞定,郁闷ing\n" + - "\t\t(4小时前 by 午后冬日)\n" + - "\t\t回复\n" + - "\t\t\n" + - "\t\t
        \n" + - "\t
      • \n" + - "\t
      \n" + - "\n" + - "
      \n" + - "\t
      \t\t\t\t\t\t有帮助(0) |\n" + - "\t\t没帮助(0) |\n" + - "\t\t评论(1) |\n" + - " \t引用此答案\t
      \n" + - "
    • \n" + - "\t
      \"布谷鸟\"
      \n" + - "\t
      \n" + - "\t\t
      布谷鸟 回答于 2013-04-21 11:29
      \t\t\n" + - " \t
      \n" + - "\t\t\t \t\t \t\t举报\n" + - " \t
      \n" + - "\t\t
      \n" + - "\t\t

      引用来自“布谷鸟”的答案

      对话框、日期控件和选项卡效果还不错,树状菜单没得zTree好用,建议楼主不要全部效果都依赖于此框架,有些easyui实现不好的地方可以换其它的插件实现嘛,反正我现在再也不用诸如ext和easyui之类的东西了,感觉好肥
      前后端你一个人搞啊?那确实很麻烦。面面俱到的话,工作量很大。但是如果需要实现的功能不是很多,而时间也不紧迫的话,事情干起来也还不错。如非必须,建议逐步弃用这些前端框架,在一些比较能够提升体验的地方选用一些适当的插件即可,如此也不再需要担心风格的问题,你看osc后台截图,界面那叫一个丑,用得方便顺手就够了
      \n" + - "\t
      \n" + - "\t
      \n" + - "\t
      \n" + - "\t
      \t\t\t\t\t\t有帮助(0) |\n" + - "\t\t没帮助(0) |\n" + - "\t\t评论(0) |\n" + - " \t引用此答案\t
      \n" + - "
    \n" + - "\t\t\t\t
    \n" + - "\t\t
    \n" + - "\t\t\t
    \"黄亿华\"
    \n" + - "\t\t\t
    \n" + - "\t\t\t\t\n" + - "\t\t\t\t\n" + - "\t\t\t\t\n" + - "\t\t\t\t\n" + - "\t\t\t\t

    \n" + - "\t\t\t\t回答案顶部 | 回页面顶部\n" + - "\t\t\t
    \n" + - "\t\t\t
    \n" + - "\t\t\t\n" + - "\t\t
    \n" + - "\t
    \t\n" + - "\t\n" + - "\n" + - "\n" + - "\n" + - "\t
    \n" + - "\t
    \n" + - " \t\n" + - "\t
    \n" + - "\t\t
    \n" + - "\t\t\t有什么技术问题吗?\n" + - "\t\t\t我要提问\n" + - "\t\t\t
    \n" + - "\t\t
    \n" + - "\t\t\n" + - "\t\t\t\t\t\t
    \n" + - "\t\t\t全部(29)...午后冬日的其他问题\n" + - "\t\t\t\n" + - "\t\t
    \n" + - "\t\t\t\t
    \n" + - "\t\t\n" + - "\t\t
    \n" + - "\t\t\n" + - "\t\t
    \n" + - "\t\t\t类似的话题\n" + - "\t\t\t\n" + - "\t\t
    \n" + - "\t
    \n" + - "\t
    \n" + - "
    \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
    \n" + - "\t
    \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
    © 开源中国(OsChina.NET) | 关于我们 | 广告联系 | @新浪微博 | 开源中国手机版 | 粤ICP备12009483号-3\n" + - "\t开源中国手机客户端:\n" + - "\tAndroid\n" + - "\tiPhone\n" + - "\tWP7\n" + - "
    \n" + - "
    \n" + - "
    \n" + - "\n" + - "\n" + - ""; + private String html = "\n" + + "\n" + + "\n" + + "\n" + + " \n" + + " \n" + + " 再次吐槽easyui - 开源中国 OSChina.NET\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "
    \n" + + "\t
    \n" + + "
    \n" + + " \t\n" + + "
    \n" + + "\t\t
    \n" + + " \t\t \t\t黄亿华,您好 \n" + + "\t\t\t\n" + + "\t\t\t\t我的空间\n" + + "\t\t\t\t\n" + + "\t\t\t | \n" + + "\t\t\t添加软件 | 投递新闻 | 退出\n" + + " \t\t\t\t
    \n" + + "\t\t
    \n" + + "\t
    \n" + + "
    \n" + + "
    \n" + + "

    讨论区

    \n" + + "
    \n" + + "\t
    当前位置:
    \n" + + "\t
    \n" + + "\t\t\t\t\t \t\t讨论区 »\n" + + " \t\t技术问答\t\t\t\t\t\t\t\t» EasyUI\n" + + "\t\t\t\t\t\t\t\t\t\t
    \n" + + "
    \n" + + "\n" + + "
    \n" + + "
    \n" + + "\t
    \n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "
    \n" + + "\t\n" + + "\t
    \n" + + "\t
    \n" + + "\t\t
    \"午后冬日\"
    \n" + + "\t\t
    \n" + + "\t\t\t

    再次吐槽easyui

    \n" + + "\t\t\t
    \n" + + "\t\t\t\t午后冬日\n" + + "\t\t\t\t发表于 2013-4-21 02:28 13小时前,\n" + + "\t\t\t\t3回/289阅,\n" + + "\t\t\t\t最后回答: 4小时前\t\t\t\t\t\t\t\t\t\t\t
    \n" + + "\t\t
    \n" + + "\t\t\n" + + "\t\t
    \n" + + "\t
    \n" + + "\t\t \t \t\t\t\t\t\n" + + "\t\t

    Java、PHP、Ruby、iOS、Python 等 JetBrains 开发工具低至 99 元(3折),详情»

    \n" + + "\t\t
    \n" + + "\t\t\t\t\t\t
    刚用到easyui treegrid组件,发现这货第一次加载时候并没有传默认参数,展开某一列时候才传递id:xx的参数。这样和后台总是疙里疙瘩,像没事就拌嘴的两口子,查网上都遇到相同问题,最好解决方案就是通过 \n" + + "onBeforeExpand事件来扩展,自行解决。看到官方例子中简洁的代码,感觉easyui耍流氓了,真搞不懂为何要这样实现
    \n" + + "\t\t\t\t\t\t
    \n" + + "\t\t\t\t标签:\t\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t\t\t\tEasyUI \t\t\t\t\t\t\t\t\t\t\t
    \n" + + "\t\t\t\t\t\t
    \n" + + "\t\t\t\n" + + "\t\t\t\t\t\t\t\t\t我想问同样的问题\n" + + "\t\t\t\t\t\t\n" + + "\t\t\t共0个人想要问同样的问题\n" + + "\t\t\t\t\t\t补充话题说明»\n" + + "\t\t\t
    \n" + + "\t\t\t\t\t\t
    \n" + + "\t
      \n" + + "
      \t\t
      \n" + + "\t\t\n" + + "\t\t
      \n" + + " \n" + + "\t\t\t\t
      \n" + + "\t\t\t
      分享到
      \n" + + "\t\t\t\n" + + "\t\t\t
      1
      \n" + + "\t\t\t\n" + + "\t\t\t
      \n" + + "\t\t\t\t\t\t\t\t \t\t\t\n" + + "\t\t\t\t\t\t\t\t0\n" + + "\t\t\t\t|\n" + + "\t\t\t\t\t\t\t\t \t\t\t\n" + + "\t\t\t\t\t\t\t\t0\n" + + "\t\t\t
      \n" + + "\t\t\t\n" + + "\t\t
      \n" + + "\t\t
      \n" + + "\t\t\t\t\t\t
      \n" + + "\t\t\t\n" + + " \t

      \t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\t\t按评价排序 |\n" + + "\t\t\t\t\t显示最新答案 | 回页面顶部\n" + + "\t\t\t\t\n" + + "\t\t\t\t共有3个答案 我要回答»\n" + + "\t\t\t

      \n" + + "\t\t\t \t
      • \n" + + "\t
        \"布谷鸟\"
        \n" + + "\t
        \n" + + "\t\t
        布谷鸟 回答于 2013-04-21 09:28
        \t\t\n" + + " \t
        \n" + + "\t\t\t \t\t \t\t举报\n" + + " \t
        \n" + + "\t\t
        \n" + + "\t\t
        对话框、日期控件和选项卡效果还不错,树状菜单没得zTree好用,建议楼主不要全部效果都依赖于此框架,有些easyui实现不好的地方可以换其它的插件实现嘛,反正我现在再也不用诸如ext和easyui之类的东西了,感觉好肥
        \n" + + "\t
        \n" + + "\t
        \n" + + "\t
        --- 共有 1 条评论 --- \n" + + "
          \n" + + "\t\t
        • \n" + + "\t\t\"午后冬日\"\n" + + "\t\t\n" + + "\t\t前端水平实在有限,自己搞的总是感觉不伦不类,只能用这些框架,再集成其它插件,切换主题时风格又不一致。\n" + + "\t\t(4小时前 by 午后冬日)\n" + + "\t\t回复\n" + + "\t\t\n" + + "\t\t
          \n" + + "\t
        • \n" + + "\t
        \n" + + "\n" + + "
        \n" + + "\t
        \t\t\t\t\t\t有帮助(1) |\n" + + "\t\t没帮助(0) |\n" + + "\t\t评论(1) |\n" + + " \t引用此答案\t
        \n" + + "
      • \n" + + "\t
        \"静风流云\"
        \n" + + "\t
        \n" + + "\t\t
        静风流云 回答于 2013-04-21 11:08
        \t\t\n" + + " \t
        \n" + + "\t\t\t \t\t \t\t举报\n" + + " \t
        \n" + + "\t\t
        \n" + + "\t\t

        没办法,原来项目也是因为客户特殊的需求,对layout选型的时候,犹豫了好久,最终放弃了。
        幸亏来了一个厉害的前端,解决问题,够用就好。

        \n" + + "\t
        \n" + + "\t
        \n" + + "\t
        --- 共有 1 条评论 --- \n" + + "
          \n" + + "\t\t
        • \n" + + "\t\t\"午后冬日\"\n" + + "\t\t\n" + + "\t\t我也是犹豫了好久,看过很多前端框架,总是不太满意。个人开发前台后台数据库全部要自己搞定,郁闷ing\n" + + "\t\t(4小时前 by 午后冬日)\n" + + "\t\t回复\n" + + "\t\t\n" + + "\t\t
          \n" + + "\t
        • \n" + + "\t
        \n" + + "\n" + + "
        \n" + + "\t
        \t\t\t\t\t\t有帮助(0) |\n" + + "\t\t没帮助(0) |\n" + + "\t\t评论(1) |\n" + + " \t引用此答案\t
        \n" + + "
      • \n" + + "\t
        \"布谷鸟\"
        \n" + + "\t
        \n" + + "\t\t
        布谷鸟 回答于 2013-04-21 11:29
        \t\t\n" + + " \t
        \n" + + "\t\t\t \t\t \t\t举报\n" + + " \t
        \n" + + "\t\t
        \n" + + "\t\t

        引用来自“布谷鸟”的答案

        对话框、日期控件和选项卡效果还不错,树状菜单没得zTree好用,建议楼主不要全部效果都依赖于此框架,有些easyui实现不好的地方可以换其它的插件实现嘛,反正我现在再也不用诸如ext和easyui之类的东西了,感觉好肥
        前后端你一个人搞啊?那确实很麻烦。面面俱到的话,工作量很大。但是如果需要实现的功能不是很多,而时间也不紧迫的话,事情干起来也还不错。如非必须,建议逐步弃用这些前端框架,在一些比较能够提升体验的地方选用一些适当的插件即可,如此也不再需要担心风格的问题,你看osc后台截图,界面那叫一个丑,用得方便顺手就够了
        \n" + + "\t
        \n" + + "\t
        \n" + + "\t
        \n" + + "\t
        \t\t\t\t\t\t有帮助(0) |\n" + + "\t\t没帮助(0) |\n" + + "\t\t评论(0) |\n" + + " \t引用此答案\t
        \n" + + "
      \n" + + "\t\t\t\t
      \n" + + "\t\t
      \n" + + "\t\t\t
      \"黄亿华\"
      \n" + + "\t\t\t
      \n" + + "\t\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\t

      \n" + + "\t\t\t\t回答案顶部 | 回页面顶部\n" + + "\t\t\t
      \n" + + "\t\t\t
      \n" + + "\t\t\t\n" + + "\t\t
      \n" + + "\t
      \t\n" + + "\t\n" + + "\n" + + "\n" + + "\n" + + "\t
      \n" + + "\t
      \n" + + " \t\n" + + "\t
      \n" + + "\t\t
      \n" + + "\t\t\t有什么技术问题吗?\n" + + "\t\t\t我要提问\n" + + "\t\t\t
      \n" + + "\t\t
      \n" + + "\t\t\n" + + "\t\t\t\t\t\t
      \n" + + "\t\t\t全部(29)...午后冬日的其他问题\n" + + "\t\t\t\n" + + "\t\t
      \n" + + "\t\t\t\t
      \n" + + "\t\t\n" + + "\t\t
      \n" + + "\t\t\n" + + "\t\t
      \n" + + "\t\t\t类似的话题\n" + + "\t\t\t\n" + + "\t\t
      \n" + + "\t
      \n" + + "\t
      \n" + + "
      \n" + + "\n" + + "\n" + + "\n" + + "\n" + + "
      \n" + + "\t
      \n" + + "\n" + + "\n" + + "\n" + + "\n" + "
      © 开源中国(OsChina.NET) | 关于我们 | 广告联系 | @新浪微博 | 开源中国手机版 | 粤ICP备12009483号-3\n" + "\t开源中国手机客户端:\n" + + "\tAndroid\n" + + "\tiPhone\n" + + "\tWP7\n" + "
      \n" + "
      \n" + + "
      \n" + "\n" + "\n" + + ""; @Test - public void test(){ - String text = "\n" + - "\n" + - "\n" + - " \n" + - " \n" + - " jsoup 解析页面商品信息 - - ITeye技术网站\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - "\n" + - "\n" + - " \n" + - " \n" + - "\n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
      \n" + - "
      \n" + - " 首页\n" + - " 资讯\n" + - " 精华\n" + - " 论坛\n" + - " 问答\n" + - " 博客\n" + - " 专栏\n" + - " 群组\n" + - " 更多 \n" + - "
      \n" + - " 招聘\n" + - " 搜索\n" + - "
      \n" + - "
      \n" + - "\n" + - "
      \n" + - " \n" + - " 欢迎flashsword20\n" + - " 0\n" + - " \n" + - " \"Newpm\"收件箱(3)\n" + - " \n" + - " 我的应用\n" + - "
      \n" + - " 我的关注\n" + - " 我的群组\n" + - " 我的简历\n" + - " 我的相册\n" + - " 我的收藏\n" + - " 我的代码\n" + - " 我的微博\n" + - "
      \n" + - " 我的博客\n" + - " 设置\n" + - "
      \n" + - "
      \n" + - " \n" + - " \n" + - "
      \n" + - "
      \n" + - " \n" + - " \n" + - "
      \n" + - "
      \n" + - "
      \n" + - "
      \n" + - "
      \n" + - " \n" + - "
      \n" + - "
      \n" + - " \n" + - "\n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "
      \n" + - "
      \n" + - "

      \n" + - " jsoup 解析页面商品信息\n" + - " \n" + - "

      \n" + - " \n" + - "
       
      \n" + - "
      \n" + - "\n" + - "
      \n" + - "

      今天用了jsoup 解析页面商品信息,感觉比用xpath获取信息准确多了

      \n" + - "

      \n" + - "

      下面就记录一下:

      \n" + - "

      一、首先去 http://jsoup.org/download 下载jsoup的jar包。

      \n" + - "

      \n" + - "

      二、下面记录下相关代码:

      \n" + - "

      \n" + - "

      \n" + - "

      Document doc = Jsoup.connect(url).get(); //将htm转换成Document类型数据结构

      \n" + - "


      doc.select(\"div:has(div) div#spec-n1:has(img) img\").first().attr(\"src\")); //查找div下含有div的标签

      \n" + - "

      \n" + - "

      并且 div的id='spec-n1',此div第一个img标签,img里属性是src的值。

      \n" + - "

      \n" + - "

      doc.select(\"div:has(div) div.crumb:has(a) a:eq(4)\").text(); //查找class='crumb'的div下第4个a标签

      \n" + - "

      下的值。

      \n" + - "

      \n" + - "

      doc.select(\"div:has(div) div#name:has(h1)\").text(); //查找id='name'的div下的h1标签的值。

      \n" + - "

      \n" + - "

      doc.select(\"tbody:has(tr) td.tdTitle:contains(品牌) + td\").text(); //查找class='tdTitle'的td标签里

      \n" + - "

      \n" + - "

      含有‘品牌’td的下一个td标签中内容。

      \n" + - "

      \n" + - "

      doc.select(\"script[type=text/javascript]:not([src~=[a-zA-Z0-9./\\\\s]+)\"); //查找含有此<script

      \n" + - "

      \n" + - "

      type=\"text/javascript\">……</script>内容,不含有script标签中有src属性的script,如:

      \n" + - "

      \n" + - "

      <script src=\"url\" type=\"text/javascript\"></script>。

      \n" + - "
      \n" + - "\n" + - " \n" + - "\n" + - "\n" + - " \n" + - " \n" + - "
      \n" + - " \n" + - "
      分享到:\n" + - " \n" + - " \n" + - "
      \n" + - "
      \n" + - "\n" + - " \n" + - "
      \n" + - " \n" + - "
      \n" + - "\n" + - "
      \n" + - "
      评论
      \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "
      \n" + - "\n" + - "
      \n" + - "
      发表评论
      \n" + - "
      \n" + - "\n" + - "\n" + - " \n" + - "\n" + - "\n" + - "\n" + - "
      \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "

      (快捷键 Alt+S / Ctrl+Enter)

      \n" + - "
      \n" + - " \n" + - "
      \n" + - "
      \n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "\n" + - "
      \n" + - "\n" + - "
      \n" + - "
      \n" + - "
      \n" + - "
      \"masong1987的博客\"
      \n" + - "
      masong1987
      \n" + - "
      \n" + - "\n" + - "
      \n" + - "
        \n" + - "
      • 浏览: 5401 次
      • \n" + - "
      • 性别: \"Icon_minigender_1\"
      • \n" + - "
      • 来自: 北京
      • \n" + - "
      • \n" + - " \n" + - "
      • \n" + - " 发短消息\n" + - " \n" + - " 更多访客>>\n" + - " \n" + - "
        \n" + - "
        \"flashsword20的博客\"
        \n" + - " \n" + - "
        \n" + - " \n" + - "
        \n" + - "
        \"dylinshi126的博客\"
        \n" + - " \n" + - "
        \n" + - " \n" + - "
        \n" + - "
        \"machoo的博客\"
        \n" + - " \n" + - "
        \n" + - " \n" + - "
        \n" + - "
        \"arson的博客\"
        \n" + - " \n" + - "
        \n" + - " \n" + - "
      \n" + - "\n" + - " \n" + - "\n" + - "
      \n" + - "
      文章分类
      \n" + - " \n" + - "
      \n" + - "
      \n" + - "
      社区版块
      \n" + - " \n" + - "
      \n" + - "
      \n" + - "
      存档分类
      \n" + - " \n" + - "
      \n" + - " \n" + - " \n" + - "\n" + - "
      \n" + - "
      最新评论
      \n" + - " \n" + - "
      \n" + - "\n" + - "
      \n" + - " \n" + - "
      \n" + - "
      \n" + - "\n" + - "
      \n" + - "
      \n" + - "
      \n" + - " 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。若作者同意转载,必须以超链接形式标明文章原始出处和作者。
      \n" + - " © 2003-2012 ITeye.com. All rights reserved. [ 京ICP证110151号 京公网安备110105010620 ]\n" + - "
      \n" + - "
      \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - "\n"; - String text2="
      aaa
      "; - XpathSelector xpathSelector = new XpathSelector("//div[@id='main']/div[@class='blog_main']/div[1][@class='blog_title']/h3/a"); + public void test() { + String text = "\n" + + "\n" + + "\n" + + " \n" + + " \n" + + " jsoup 解析页面商品信息 - - ITeye技术网站\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + " \n" + + " \n" + + "\n" + + "\n" + + " \n" + + " \n" + + "\n" + + " \n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
      \n" + + "
      \n" + + " 首页\n" + + " 资讯\n" + + " 精华\n" + + " 论坛\n" + + " 问答\n" + + " 博客\n" + + " 专栏\n" + + " 群组\n" + + " 更多 \n" + + "
      \n" + + " 招聘\n" + + " 搜索\n" + + "
      \n" + + "
      \n" + + "\n" + + "
      \n" + + " \n" + + " 欢迎flashsword20\n" + + " 0\n" + + " \n" + + " \"Newpm\"收件箱(3)\n" + + " \n" + + " 我的应用\n" + + "
      \n" + + " 我的关注\n" + + " 我的群组\n" + + " 我的简历\n" + + " 我的相册\n" + + " 我的收藏\n" + + " 我的代码\n" + + " 我的微博\n" + + "
      \n" + + " 我的博客\n" + + " 设置\n" + + "
      \n" + + "
      \n" + + " \n" + + " \n" + + "
      \n" + + "
      \n" + + " \n" + + " \n" + + "
      \n" + + "
      \n" + + "
      \n" + + "
      \n" + + "
      \n" + + " \n" + + "
      \n" + + "
      \n" + + " \n" + + "\n" + + "\n" + + "\n" + + " \n" + + "\n" + + "\n" + + "
      \n" + + "
      \n" + + "

      \n" + + " jsoup 解析页面商品信息\n" + + " \n" + + "

      \n" + + " \n" + + "
       
      \n" + + "
      \n" + + "\n" + + "
      \n" + + "

      今天用了jsoup 解析页面商品信息,感觉比用xpath获取信息准确多了

      \n" + + "

      \n" + + "

      下面就记录一下:

      \n" + + "

      一、首先去 http://jsoup.org/download 下载jsoup的jar包。

      \n" + + "

      \n" + + "

      二、下面记录下相关代码:

      \n" + + "

      \n" + + "

      \n" + + "

      Document doc = Jsoup.connect(url).get(); //将htm转换成Document类型数据结构

      \n" + + "


      doc.select(\"div:has(div) div#spec-n1:has(img) img\").first().attr(\"src\")); //查找div下含有div的标签

      \n" + + "

      \n" + + "

      并且 div的id='spec-n1',此div第一个img标签,img里属性是src的值。

      \n" + + "

      \n" + + "

      doc.select(\"div:has(div) div.crumb:has(a) a:eq(4)\").text(); //查找class='crumb'的div下第4个a标签

      \n" + + "

      下的值。

      \n" + + "

      \n" + + "

      doc.select(\"div:has(div) div#name:has(h1)\").text(); //查找id='name'的div下的h1标签的值。

      \n" + + "

      \n" + + "

      doc.select(\"tbody:has(tr) td.tdTitle:contains(品牌) + td\").text(); //查找class='tdTitle'的td标签里

      \n" + + "

      \n" + + "

      含有‘品牌’td的下一个td标签中内容。

      \n" + + "

      \n" + + "

      doc.select(\"script[type=text/javascript]:not([src~=[a-zA-Z0-9./\\\\s]+)\"); //查找含有此<script

      \n" + + "

      \n" + + "

      type=\"text/javascript\">……</script>内容,不含有script标签中有src属性的script,如:

      \n" + + "

      \n" + + "

      <script src=\"url\" type=\"text/javascript\"></script>。

      \n" + + "
      \n" + + "\n" + + " \n" + + "\n" + + "\n" + + " \n" + + " \n" + + "
      \n" + + " \n" + + "
      分享到:\n" + + " \n" + + " \n" + + "
      \n" + + "
      \n" + + "\n" + + " \n" + + "
      \n" + + " \n" + + "
      \n" + + "\n" + + "
      \n" + + "
      评论
      \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
      \n" + + "\n" + + "
      \n" + + "
      发表评论
      \n" + + "
      \n" + + "\n" + + "\n" + + " \n" + + "\n" + + "\n" + + "\n" + + "
      \n" + + "\n" + + "\n" + + "\n" + + "\n" + + "

      (快捷键 Alt+S / Ctrl+Enter)

      \n" + + "
      \n" + + " \n" + + "
      \n" + + "
      \n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "
      \n" + + "\n" + + "
      \n" + + "
      \n" + + "
      \n" + + "
      \"masong1987的博客\"
      \n" + + "
      masong1987
      \n" + + "
      \n" + + "\n" + + "
      \n" + + "
        \n" + + "
      • 浏览: 5401 次
      • \n" + + "
      • 性别: \"Icon_minigender_1\"
      • \n" + + "
      • 来自: 北京
      • \n" + + "
      • \n" + + " \n" + + "
      • \n" + + " 发短消息\n" + + " \n" + + " 更多访客>>\n" + + " \n" + + "
        \n" + + "
        \"flashsword20的博客\"
        \n" + + " \n" + + "
        \n" + + " \n" + + "
        \n" + + "
        \"dylinshi126的博客\"
        \n" + + " \n" + + "
        \n" + + " \n" + + "
        \n" + + "
        \"machoo的博客\"
        \n" + + " \n" + + "
        \n" + + " \n" + + "
        \n" + + "
        \"arson的博客\"
        \n" + + " \n" + + "
        \n" + + " \n" + + "
      \n" + + "\n" + + " \n" + + "\n" + + "
      \n" + + "
      文章分类
      \n" + + " \n" + + "
      \n" + + "
      \n" + + "
      社区版块
      \n" + + " \n" + + "
      \n" + + "
      \n" + + "
      存档分类
      \n" + + " \n" + + "
      \n" + + " \n" + + " \n" + + "\n" + + "
      \n" + + "
      最新评论
      \n" + + " \n" + + "
      \n" + + "\n" + + "
      \n" + + " \n" + + "
      \n" + + "
      \n" + + "\n" + + "
      \n" + + "
      \n" + + "
      \n" + + " 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。若作者同意转载,必须以超链接形式标明文章原始出处和作者。
      \n" + + " © 2003-2012 ITeye.com. All rights reserved. [ 京ICP证110151号 京公网安备110105010620 ]\n" + + "
      \n" + + "
      \n" + + " \n" + + " \n" + "\n" + " \n" + " \n" + " \n" + "\n"; + String text2 = "
      aaa
      "; + XpathSelector xpathSelector = new XpathSelector( + "//div[@id='main']/div[@class='blog_main']/div[1][@class='blog_title']/h3/a"); String select = xpathSelector.select(text); - Assert.assertEquals("jsoup 解析页面商品信息",select); + Assert.assertEquals("jsoup 解析页面商品信息", select); } @Test - public void testOschina(){ + public void testOschina() { Html html1 = new Html(html); - Assert.assertEquals("再次吐槽easyui",html1.x(".//*[@class='QTitle']/h1/a").toString()); + Assert.assertEquals("再次吐槽easyui", html1.x(".//*[@class='QTitle']/h1/a").toString()); } - @Test - public void testOschinaBlog(){ - Html html1 = new Html(blogHtml); - System.out.println(html1.sc()); - } - - @Test - public void testHuxiuBlog(){ - Html html1 = new Html(huxiuHtml); - System.out.println(html1.sc()); - } } diff --git a/webmagic-core/src/test/resources/log4j.xml b/webmagic-core/src/test/resources/log4j.xml index a58e889b..9084694e 100644 --- a/webmagic-core/src/test/resources/log4j.xml +++ b/webmagic-core/src/test/resources/log4j.xml @@ -24,7 +24,7 @@ - + diff --git a/webmagic-samples/src/test/java/us/codecraft/webmagic/HtmlTest.java b/webmagic-samples/src/test/java/us/codecraft/webmagic/HtmlTest.java deleted file mode 100644 index f7990984..00000000 --- a/webmagic-samples/src/test/java/us/codecraft/webmagic/HtmlTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package us.codecraft.webmagic; - -import org.junit.Assert; -import org.junit.Test; -import us.codecraft.webmagic.selector.Html; - -/** - * User: cairne - * Date: 13-4-21 - * Time: 上午8:42 - */ -public class HtmlTest { - - @Test - public void testRegexSelector() { - Html selectable = new Html("aaaaaaab"); - Assert.assertEquals("abbabbab", (selectable.r("(.*)").rp("aa(a)", "$1bb").toString())); - - } -} diff --git a/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java b/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java index 838c76b8..6f795d74 100644 --- a/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java +++ b/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java @@ -15,12 +15,14 @@ import us.codecraft.webmagic.schedular.FileCacheQueueSchedular; public class SpiderTest { + @Ignore @Test public void testSpider() throws InterruptedException { Spider me = Spider.me().pipeline(new FilePipeline()).processor(new HuxiuProcessor()); me.run(); } + @Ignore @Test public void testGlobalSpider(){ // PageProcessor pageProcessor = new MeicanProcessor(); @@ -35,6 +37,7 @@ public class SpiderTest { } + @Ignore @Test public void test(){ System.out.println(System.getProperty("java.io.tmpdir")); diff --git a/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiandianProcessorTest.java b/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiandianProcessorTest.java index 18b0680d..63021342 100644 --- a/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiandianProcessorTest.java +++ b/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiandianProcessorTest.java @@ -1,5 +1,6 @@ package us.codecraft.webmagic.processor; +import org.junit.Ignore; import org.junit.Test; import us.codecraft.webmagic.Spider; import us.codecraft.webmagic.pipeline.ConsolePipeline; @@ -16,6 +17,7 @@ import java.io.IOException; */ public class DiandianProcessorTest { + @Ignore @Test public void test() throws IOException { DiandianBlogProcessor diaoyuwengProcessor = new DiandianBlogProcessor(); diff --git a/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiaoyuwengProcessorTest.java b/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiaoyuwengProcessorTest.java index 1e77c7c7..18498d36 100644 --- a/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiaoyuwengProcessorTest.java +++ b/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/DiaoyuwengProcessorTest.java @@ -1,5 +1,6 @@ package us.codecraft.webmagic.processor; +import org.junit.Ignore; import org.junit.Test; import us.codecraft.webmagic.Spider; import us.codecraft.webmagic.pipeline.FilePipeline; @@ -16,6 +17,7 @@ import java.io.IOException; */ public class DiaoyuwengProcessorTest { + @Ignore @Test public void test() throws IOException { DiaoyuwengProcessor diaoyuwengProcessor = new DiaoyuwengProcessor(); diff --git a/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/SinablogProcessorTest.java b/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/SinablogProcessorTest.java index 0a5cc1b0..1fada819 100644 --- a/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/SinablogProcessorTest.java +++ b/webmagic-samples/src/test/java/us/codecraft/webmagic/processor/SinablogProcessorTest.java @@ -1,5 +1,6 @@ package us.codecraft.webmagic.processor; +import org.junit.Ignore; import org.junit.Test; import us.codecraft.webmagic.Spider; import us.codecraft.webmagic.pipeline.FilePipeline; @@ -16,6 +17,7 @@ import java.io.IOException; */ public class SinablogProcessorTest { + @Ignore @Test public void test() throws IOException { SinaBlogProcesser sinaBlogProcesser = new SinaBlogProcesser();