`

webharvest

阅读更多
a.xml
<?xml version="1.0" encoding="UTF-8"?>
   <config charset="UTF-8">
<var-def name="freelist">  

       <xpath expression="//tbody[@id]">
               <html-to-xml>  
                 <http url="${targetUrl}"/>  
              </html-to-xml>  
            </xpath>  
        </var-def>  
           
    <file action="write" path="c.xml">  
        
       <template>  
           <![CDATA[ <root> ]]>  
       </template>  
         
 
       <loop item="freeitem" index="i">  
          <list>  
            <var name="freelist"/>  
          </list>  
          <body>  
             <xquery>  
                    <xq-param name="freeitem">  
                        <var name="freeitem"/>  
                    </xq-param>  
                    <xq-expression><![CDATA[  
                        declare variable $freeitem as node() external;  
    let $title := data($freeitem//tr/th[@class]/span[@id]/a[1])  
     let $strong := data($freeitem//tr/td[@class='nums']/strong[1])  
   let $em := data($freeitem//tr/td[@class='nums']/em[1])  
     
return 
 <result>
 <title>{normalize-space($title)}    </title>
 <total>{normalize-space($strong)}    </total>
 <num>{normalize-space($em)}    </num>
</result>
 
                    ]]></xq-expression>  
                </xquery>  
          </body>  
       </loop>  
   
      <![CDATA[ </root> ]]>  
    </file>
	</config>

 test.java

 

	  ScraperConfiguration config = new ScraperConfiguration("a.xml");
    Scraper scraper = new Scraper(config, "eee/");
    scraper.addVariableToContext("targetUrl", new String("http://bbs.cdream.com/forumdisplay.php?fid=51"));//这里主
    scraper.setDebug(true);
    scraper.execute();

 

分享到:
评论

相关推荐

    webharvest 中文翻译文档

    1. webharvest官方网站参考手册地址: http://web-harvest.sourceforge.net/manual.php 2. 一个介绍XPath、XQuery 以及 XSLT 函数的网址 http://www.w3school.com.cn/xpath/xpath_functions.asp 3. 另一个参考地址 ...

    webharvest基础教程 pdf

    webharvest基础教程:入门者的好书.

    webharvest_API参考文档.CHM

    webharvest_API参考文档.CHM webharvest_API参考文档.CHM

    webharvest_all_2.jar

    webharvest_all_2.jar

    HTML_500 for webharvest

    HTML_500 for webharvest, this is for webharvest testing.

    webharvest1-bin.zip

    webharvest是一个开源的java桌面程序,能够从论坛、网站上下载定制你自己想要的东西。因为开源,所以很好用,同时也是一个学习java和xml的好东西

    WebHarvest开源框架

    利用此框架即配置文件可以抓取网上的数据,此框架开源,欢迎下载

    WebHarvest中文文档

    WebHarvest各种方法及应用的详细介绍

    Webharvest爬虫

    Webharvest爬虫

    webharvest源码

    网络爬虫,webharvest源码,通过配置文件对指定网站进行爬去

    开源WebHarvest抓取实例

    1. template目录下的三个模板分别是 sina_1. 抓取全网财经要闻-新浪(一条新闻) sina_2. 抓取主流财经网站要闻区-新浪(列表新闻) sina_3....sina_3_img 保存了图文混合的图片 2. 实例采用了XQuery表达式[loop、...

    java开源软件项目网络爬虫-webharvest

    The main goal behind Web-Harvest is to empower the usage of already existing extraction technologies. Its purpose is not to propose a new method, but to provide a way to easily use and combine the ...

    web-harvest

    NULL 博文链接:https://xpenxpen.iteye.com/blog/1101618

    web-harvest解析及源文件

    里面有学习web_harvest的学习方法,还有一些源文件,其中-txt文件中文件可以直接运行XML文件进行操作,而另外的文件中用需要的JAR文件和导入到程序中使用的一些JAVA文件,希望对大家有用!

    java导出excel表格源码下载-rpa_samples:AutomationAcademy.com上的RPA课程示例

    webharvest 库的示例 - 如何使用 web-harvest 命令访问java/groovy变量。 - 变量声明和使用。 - 创建纯文本文件并将其上传到 S3。 - 读取数据存储并记录其字段。 - 访问 ftp-server 并记录其内容(文件、目录、链接...

    webharvset爬虫抓取

    webharvset爬虫抓取的jar及简单及基础教程

Global site tag (gtag.js) - Google Analytics