Releases: code4craft/webmagic
WebMaigc-0.5.0
此次更新主要增加了监控功能,同时重写了多线程部分,使得多线程下性能有了极大的提升。另外还包含注解模式一些优化、多页面的支持等功能。
项目总体进展:
- 官网webmagic.io上线了!同时上线的还有详细版的官方文档http://webmagic.io/docs,从此使用更加简单!
- 新增三名合作开发者@ccliangbo @ouyanghuangzheng @linkerlin ,一起参与项目的维护。
- 官方论坛http://bbs.webmagic.io/和官方QQ群373225642上线,以后会更加重视社区的建设。
监控部分:
- 增加了监控功能,使用JMX可以监控页面数量、爬虫状态,并可以启动和终止爬虫。使用文档:http://webmagic.io/docs/posts/ch4-basic-page-processor/monitor.html #98
多线程部分:
- 重写了多线程部分,修复了多线程下,主分发线程会被工作线程阻塞的问题,使得多线程下效率有了极大的提升,推荐所有用户升级。 #110
- 为主线程等待新URL时的wait/notify机制增加了timeout时间,防止少数情况下发生的爬虫卡死的情况。 #111
抽取API部分:
- 增加了JSON的支持,现在可以使用
page.getJson().jsonPath()
来使用jsonPath解析AJAX请求,也可以使用page.getJson().removePadding().jsonPath()
来解析JSONP请求。 #101 - 修复一个Selectable的缓存导致两次取出的结果不一致的问题。 #73 感谢@seveniu 发现问题
- 支持为一个Spider添加多个PageProcessor,并按照URL区分,感谢@sebastian1118 提交patch。使用示例:PatternProcessorExample #86
- 修复不常用标签无法使用
nth-of-type
选择的问题(例如//div/svg[2]
) 。#75 - 修复XPath中包含特殊字符,即使转义也会导致解析失败的问题。#77
注解模式:
- 注解模式现在支持继承了!父类的注解将对子类也有效。#103
- 修复注解模式下,一个Spider使用多个Model时,可能不生效的问题,感谢 @ccliangbo 发现此问题。#85
- 修复sourceRegion中只有一个URL会被抽取出来的问题,感谢@jsinak 发现此问题。#107
- 修复了自动类型转换Formatter的一个BUG,现在可以自定义Formatter了。如果你不了解Formatter可以看这里:注解模式下结果的类型转换 #100
其他组件:
WebMaigc-0.4.3
webmagic-0.4.2
webmagic-0.4.1
- Fix some concurrent problem causing the spider not exit after all pages are downloaded. #36
- #38 Use algorithm of https://code.google.com/p/cx-extractor/.
More support for ajax:
webmagic-0.4.0
Improve performance of Downloader.
- Update HttpClient to 4.3.1 and rewrite the code of HttpClientDownloader #32.
- Use gzip by default to reduce the transport cost #31.
- Enable HTTP Keep-Alive and connection persistence, fix the wrong usage of PoolConnectionManage r#30.
The performance of Downloader is improved by 90% in my test.Test code: Kr36NewsModel.java.
Add synchronzing API for small task #28.
OOSpider ooSpider = OOSpider.create(Site.me().setSleepTime(100), BaiduBaike.class);
BaiduBaike baike = ooSpider.<BaiduBaike>get("http://baike.baidu.com/search/word?word=httpclient&pic=1&sug=1&enc=utf8");
System.out.println(baike);
More config for site
- Http proxy support by Site.setHttpProxy #22.
- More http header customizing support by Site.addHeader #27.
- Allow disable gzip by Site.setUseGzip(false).
- Move Site.addStartUrl to Spider.addUrl because I think startUrl is more a Spider's property than Site.
Code refactor in Spider
- Refactor the multi-thread part of Spider and fix some concurrent problem.
- Import Google Guava API for simpler code.
- Allow add request with more information by Spider.addRequest() instead of addUrl #29.
- Allow just downloading start urls without spawn urls extracted by Spider.setSpawnUrl(false).
webmagic-0.3.2
- #13 Add class cast to annotation crawler.
- Allow customize class caster by implementing
ObjectFormatter
and register it inObjectFormatters.put()
. - Fix a thread pool reject exception when call Spider.stop()
webmagic-0.3.1
webmagic-0.3.0
-
Change default XPath selector from HtmlCleaner to Xsoup.
Xsoup is an XPath selector based on Jsoup written by me. It has much better performance than HtmlCleaner.
Time of processing a page is reduced from 7~9ms to 0.4ms.
If Xsoup is not stable for your usage, just use
Spider.xsoupOff()
to turn off it and report an issue to me! -
Add cycle retry times for Site.
When cycle retry times is set, Spider will put the url which downloading failed back to scheduler, and retry after a cycle of queue.
webmagic-0.2.1
ComboExtractor support for annotation.
Request priority support (using PriorityScheduler
).
Complete some I18n work (comments and documents).
More convenient extractor API:
-
Add attribute name select for CSSSelector.
-
Group of regex selector can be specified.
-
Add OrSelector.
-
Add Selectors, import static Selectors.* for fluent API such as:
or(regex("<title>(.*)</title>"), xpath("//title"), $("title")).select(s);
-
Add JsonPathSelector for Json parse.
version-0.2.0
此次更新的主题是"方便"(之前的主题是"灵活")。
增加了webmagic-extension模块。
增加了注解方式支持,可以通过POJO+注解的方式编写一个爬虫,更符合Java开发习惯。以下是抓取一个博客的完整代码:
@TargetUrl("http://my.oschina.net/flashsword/blog/\\d+")
public class OschinaBlog {
@ExtractBy("//title")
private String title;
@ExtractBy(value = "div.BlogContent",type = ExtractBy.Type.Css)
private String content;
@ExtractBy(value = "//div[@class='BlogTags']/a/text()", multi = true)
private List<String> tags;
public static void main(String[] args) {
OOSpider.create(Site.me().addStartUrl("http://my.oschina.net/flashsword/blog"),
new ConsolePageModelPipeline(), OschinaBlog.class)
.scheduler(new RedisScheduler("127.0.0.1")).thread(5).run();
}
}
增加一个Spider.test(url)方法,用于开发爬虫时进行调试。
增加基于redis的分布式支持。
增加XPath2.0语法支持(webmagic-saxon模块)。
增加基于Selenium的浏览器渲染支持,用于抓取动态加载内容(webmagic-selenium模块)。
修复了不支持https的bug。
补充了文档:webmagic-0.2.0用户手册。