Skip to content

Releases: code4craft/webmagic

WebMagic-0.5.2

04 Jun 14:20
Compare
Choose a tag to compare

此次主要包括对于Selector部分的重构,以及一些功能的完善和一些Bugfix。

  • 重构了Selector部分,使得结构更清晰,并且能够更好的支持链式的XPath抽取了。 [Issue #113]

  • 支持对于选取出来的结果,进行外部迭代。例如:

    List<Selectable> divs = html.xpath("//div").nodes();
    for (Selectable div : divs) {
        System.out.println(div.xpath("//h2").get());
    }
  • 增强自动编码识别机制,现在除了从HTTP头中,还会从HTML Meta信息中判断编码,感谢@fengwuze @sebastian1118提交代码和建议。[Issue #126]

  • 升级Xsoup版本为0.2.4,增加了判断XPath最终抽取结果(是元素还是属性)的API,完善了一些特殊字符处理的功能。

  • 增加PageMapper功能,以后可以在任何地方使用注解模式来解析页面了![Issue #120] 例如:

    public void process(Page page) {
            //新建Mapper,GithubRepo是一个带注解的POJO
            PageMapper<GithubRepo> githubRepoPageMapper = new PageMapper<GithubRepo>(GithubRepo.class);
            //直接解析页面,得到解析后的结果
            GithubRepo githubRepo = githubRepoPageMapper.get(page);
            page.putField("repo",githubRepo);
        }
  • 增加多个代理以及智能切换的支持,感谢@yxssfxwzy 贡献代码,使用Site.setHttpProxyPool可开启此功能。[Pull #128]

    public void process(Page page) {
            Site site = Site.me().setHttpProxyPool(
                    Lists.newArrayList(
                            new String[]{"192.168.0.2","8080"},
                            new String[]{"192.168.0.3","8080"}));
        }

Bugfix:

  • 修复了JsonFilePipeline不能自动创建文件夹的问题。[Issue #122]
  • 修复了Jsonp在removePadding时,对于特殊字符匹配不当的问题。[Issue #124]
  • 修复了当JsonPathSelector选取的结果是非String类型时,类型转换出错的问题。[Issue #129]

WebMagic 0.5.1

02 May 22:26
Compare
Choose a tag to compare

此次更新主要包括Scheduler的一些改动,对于自己定制过Scheduler的用户,强烈推荐升级。

  • 修复了RedisScheduler无法去重的BUG,感谢@codev777 仔细测试并发现问题。 #117
  • 对Scheduler进行了重构,新增了接口DuplicateRemover,将去重单独抽象出来,以便在同一个Scheduler中选择不同的去重方式。 #118
  • 增加了BloomFilter去重方式。BloomFilter是一种可以用极少的内存消耗完成大量URL去重的数据结构,缺点是会有少量非重复的URL被判断为重复,导致URL丢失(小于0.5%)。

使用以下的方式即可将默认的HashSet去重改为BloomFilter去重:

spider.setScheduler(new QueueScheduler()
.setDuplicateRemover(new BloomFilterDuplicateRemover(10000000)) //10000000是估计的页面数量

WebMaigc-0.5.0

27 Apr 05:10
Compare
Choose a tag to compare

此次更新主要增加了监控功能,同时重写了多线程部分,使得多线程下性能有了极大的提升。另外还包含注解模式一些优化、多页面的支持等功能。

项目总体进展:

监控部分:

多线程部分:

  • 重写了多线程部分,修复了多线程下,主分发线程会被工作线程阻塞的问题,使得多线程下效率有了极大的提升,推荐所有用户升级。 #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

其他组件:

  • Downloader现在支持除了GET之外的其他几种HTTP请求了,包括POST、HEAD、PUT、DELETE、TRACE,感谢@usenrong 提出建议。 #108
  • Site中设置Cookie时,可以指定域名,而不是只能使用默认域名了。 #109
  • setScheduler()方法在调用时,如果之前Scheduler已有URL,会先转移到新的Scheduler,避免URL丢失。 #104
  • 在发布包中去掉了log4j.xml,避免与用户程序冲突,感谢@cnjavaer 发现问题。 #82

WebMaigc-0.4.3

13 Mar 00:28
Compare
Choose a tag to compare

Bugfix:

Enhancement:

  • Enhance RegexSelector group check #51 @SimpleExpress
  • Add XPath syntax support: #64
    contains,or/and,"|"
  • Add text attribute select to CssSelector #66
  • Change logger to slf4j #55
  • Update HttpClient version to 4.3.3 #59

webmagic-0.4.2

03 Dec 15:43
Compare
Choose a tag to compare

Enhancement:
#45 Remove multi option in ExtractBy. Auto detect whether is multi be field type.
Bugfix:
#46 Downloader thread hang up sometiems.

webmagic-0.4.1

28 Nov 05:11
Compare
Choose a tag to compare

More support for ajax:

  • #39 Parsing html after page.getHtml()
  • #42 Add jsonpath support in annotation mode
  • #35 Add more http info to page
  • #41 Add more status monitor method to Spider

webmagic-0.4.0

06 Nov 23:54
Compare
Choose a tag to compare

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

23 Sep 05:26
Compare
Choose a tag to compare
  • #13 Add class cast to annotation crawler.
  • Allow customize class caster by implementing ObjectFormatter and register it in ObjectFormatters.put().
  • Fix a thread pool reject exception when call Spider.stop()

webmagic-0.3.1

08 Sep 15:04
Compare
Choose a tag to compare
  • #26 Bugfix: Annotation extractor does not work.
  • #25 Bugfix: UrlUtils.canonicalizeUrl does not work with "../../" path.
  • #24 Enhancement: Add stop method to Spider.

webmagic-0.3.0

04 Sep 03:02
Compare
Choose a tag to compare
  • 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.