唉 终于还是决定开源这个项目,造福广大wordpress用户。
项目地址:http://code.google.com/p/jwp/
我的博客地址:http://www.ij2ee.com/
Java版wordpress采集器 如果你想流畅的使用这个项目去采集文章,你必须具备网页代码的分析能力。 你还必须会使用以下用具
firebug 或 ie developer tools
正则表达式
使用方法。
1 编写一个类,它要继承 CommonParser类 并实现两个方法
getTargetConF 文章所在的元素(比如div,p元素等等)。 这里使用htmlparser的HasAttributeFilter("id","context");方法实现的。主要是要寻找特定的属性,比如class,id,name等等。要求这些元素要唯一。
getTargetDivF 文章目录所在的元素。 这里使用htmlparser的HasAttributeFilter("id","context");方法实现的。主要是要寻找特定的属性,比如class,id,name等等。要求这些元素要唯一。
2 开始在WPMover2\src\com\wpmover2\spring\core.xml 配置相关的类属性。<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="commonP" class="com.wpmover2.parser.CommonParser" abstract="true"></bean>
<bean id="ij2ee" class="com.wpmover2.all.ij2ee.IJ2eeParser" parent="commonP">
<!-- 要采集的域名 -->
<property name="targetDomain" value="http://www.alixixi.com"/>
<!-- 要采集的目录页面url -->
<property name="targetUrl" value="http://www.alixixi.com/program/c/php_{0}.shtml"></property>
<!-- 最大采集的页面数量 这个数字将替代上面的目录页面里的{0}进行采集 -->
<property name="MAX_PAGE" value="140"></property>
<!-- 采集起始页码 同上 会替代{0}进行目录采集 -->
<property name="start_page" value="135"></property>
<!-- 目标采集页的编码格式 -->
<property name="ENCODING" value="gb2312"></property>
<!-- 因为考虑到目录页面里 还有很多其他的网页链接 所以这里请用正则匹配下真正的文章页的url -->
<property name="artUrlMatch" value="http://www.alixixi.com/program/a/\d+.shtml"/>
<!-- 我的域名 -->
<property name="mydomain" value="http://www.ij2ee.com/"></property>
<!-- 因为很多网站在文章后面会追加自己的网站名字 在这里会对采集的文章的title进行文字去除 -->
<property name="targetPlaceTxt" value="_PHP教程_编程技术"></property>
<!-- 采集的内容是采集他的html 还是只是普通的文字,普通的文字将不带有任何图片及样式等等 -->
<!-- 1是按html采集 0是采集文本 -->
<property name="useHtml" value="0"></property>
<!-- 是否是测试,测试会显示抓取的文章url 标题及文章内容,并且不会采集到博客里 -->
<!-- 1是测试 0是正式采集 -->
<property name="isTest" value="0"></property>
<!-- 我的博客的登录名 -->
<property name="user" value=""/>
<!-- 我的博客的密码 -->
<property name="pwd" value=""/>
<!--我的博客的文章标签,这里是要求文章标签和目录的一致,还有就是在采集前请确认标签和目录存不存在 -->
<property name="keyword" value="java"/>
</bean>
</beans>
项目地址:http://code.google.com/p/jwp/
我的博客地址:http://www.ij2ee.com/
Java版wordpress采集器 如果你想流畅的使用这个项目去采集文章,你必须具备网页代码的分析能力。 你还必须会使用以下用具
firebug 或 ie developer tools
正则表达式
使用方法。
1 编写一个类,它要继承 CommonParser类 并实现两个方法
getTargetConF 文章所在的元素(比如div,p元素等等)。 这里使用htmlparser的HasAttributeFilter("id","context");方法实现的。主要是要寻找特定的属性,比如class,id,name等等。要求这些元素要唯一。
getTargetDivF 文章目录所在的元素。 这里使用htmlparser的HasAttributeFilter("id","context");方法实现的。主要是要寻找特定的属性,比如class,id,name等等。要求这些元素要唯一。
2 开始在WPMover2\src\com\wpmover2\spring\core.xml 配置相关的类属性。<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="commonP" class="com.wpmover2.parser.CommonParser" abstract="true"></bean>
<bean id="ij2ee" class="com.wpmover2.all.ij2ee.IJ2eeParser" parent="commonP">
<!-- 要采集的域名 -->
<property name="targetDomain" value="http://www.alixixi.com"/>
<!-- 要采集的目录页面url -->
<property name="targetUrl" value="http://www.alixixi.com/program/c/php_{0}.shtml"></property>
<!-- 最大采集的页面数量 这个数字将替代上面的目录页面里的{0}进行采集 -->
<property name="MAX_PAGE" value="140"></property>
<!-- 采集起始页码 同上 会替代{0}进行目录采集 -->
<property name="start_page" value="135"></property>
<!-- 目标采集页的编码格式 -->
<property name="ENCODING" value="gb2312"></property>
<!-- 因为考虑到目录页面里 还有很多其他的网页链接 所以这里请用正则匹配下真正的文章页的url -->
<property name="artUrlMatch" value="http://www.alixixi.com/program/a/\d+.shtml"/>
<!-- 我的域名 -->
<property name="mydomain" value="http://www.ij2ee.com/"></property>
<!-- 因为很多网站在文章后面会追加自己的网站名字 在这里会对采集的文章的title进行文字去除 -->
<property name="targetPlaceTxt" value="_PHP教程_编程技术"></property>
<!-- 采集的内容是采集他的html 还是只是普通的文字,普通的文字将不带有任何图片及样式等等 -->
<!-- 1是按html采集 0是采集文本 -->
<property name="useHtml" value="0"></property>
<!-- 是否是测试,测试会显示抓取的文章url 标题及文章内容,并且不会采集到博客里 -->
<!-- 1是测试 0是正式采集 -->
<property name="isTest" value="0"></property>
<!-- 我的博客的登录名 -->
<property name="user" value=""/>
<!-- 我的博客的密码 -->
<property name="pwd" value=""/>
<!--我的博客的文章标签,这里是要求文章标签和目录的一致,还有就是在采集前请确认标签和目录存不存在 -->
<property name="keyword" value="java"/>
</bean>
</beans>
解决方案 »
- struts、spring、hibernate/ibatis你会删除那个?为什么?
- 急,在线等,请问:关于JFreeChart画折线的问题
- 补分专用贴“散分:初学 JAVA,请求高手指点?168分敬上。。。本贴分不够再来一贴补上。”
- weblogic platform 出现corrupted.Error code 望大侠相助理
- 急!!!关闭OracleCachedRowSet的问题。
- 部署EJB到Weblogic服务器中的时候出错,请高手指点
- 怎样修改XML文档??
- 谁能告诉我新中大的待遇怎么样?
- 在java中怎样像c语言那样接收键盘的输入
- 单元测试报错,求助大神
- 需要做一个小项目,搭建一个什么样的框架比较好?页面设计怎么做?
- Java实现调用外部程序如.exe程序
呵呵 采集器不是什么新奇的玩意啦,采集器基本上都是要钱的,什么狂人啦,火车头啦 都是收费软件。我这玩意就当给大家玩玩Java啦。