@自风 Spiderman爬虫遇到问题【抓取批量数据】
<?xml version="1.0" encoding="UTF-8"?> <!-- | Spiderman Java开源垂直网络爬虫 | author: l.weiwei@163.com | blog: http://laiweiweihi.iteye.com | qq: 493781187 | time: 2013-01-08 16:12 --> <beans> <!-- | name:名称 | url:种子链接 | reqDelay:{n}s|{n}m|{n}h|n每次请求之前延缓时间 | enable:0|1是否开启本网站的抓取 | charset:网站字符集 | schedule:调度时间,每隔多长时间重新从种子链接抓取 | thread:分配给本网站爬虫的线程数 | waitQueue:当任务队列空的时候爬虫等待多长时间再索取任务 --> <site name="all_medicine" enable="1" country="Singapore" url="http://app2.sfda.gov.cn" reqDelay="0.1s" charset="GBK" schedule="1h" thread="10" waitQueue="5s"> <!-- | HTTP Header <headers> <header name="Referer" value="http://www.straitsdeal.com/deals/" /> </headers>--> <seeds> <seed name="" url="http://app2.sfda.gov.cn/" /> </seeds> <!-- | HTTP Cookie <cookies> <cookie name="" value="" host="" path="" /> </cookies>--> <!-- | 进入任务队列的URL规则 | policy:多个rule的策略,暂时只实现了and,未来会有or --> <queueRules policy="and"> <!-- | 规则 | type:规则类型,包括 regex | equal | start | end | contains 所有规则可以在前面添加 "!" 表示取反 | value:值 --> <rule type="!regex" value="^.*.(jpg|png|gif)$" /> </queueRules> <!-- | 抓取目标 --> <targets> <!-- | name:目标名称 --> <target name="deal"> <!-- | 目标URL的规则 --> <urlRules policy="and"> <rule type="regex" value="http://app2.sfda.gov.cn/datasearchp/index1.do?tableId=25&tableName=TABLE25&tableView=葡萄糖注射液&Id=d+"> </rule> </urlRules> <!-- | 目标网页的数据模型 --> <!-- | 属性的配置 | name:属性名称 | parser:针对该属性的解析规则 --> <model isForceUseXmlParser="1"> <field name="content" isTrim="1"> <parsers> <parser xpath="//table[@class='msgtab']//tbody//tr[1]//td[1]/text()" exp="$Tags.xml($this).rm().ok()" skipErr="1"/> </parsers> </field> </model> </target> </targets> <!-- | 插件 --> <plugins> <!-- | enable:是否开启 | name:插件名 | version:插件版本 | desc:插件描述 --> <plugin enable="1" name="spider_plugin" version="0.0.1" desc="这是一个官方实现的默认插件,实现了所有扩展点。"> <!-- | 每个插件包含了对若干扩展点的实现 --> <extensions> <!-- | point:扩展点名它们包括 task_poll, begin, fetch, dig, dup_removal, task_sort, task_push, target, parse, pojo, end --> <extension point="task_poll"> <!-- | 扩展点实现类 | type: 如何获取实现类 ,默认通过无参构造器实例化给定的类名,可以设置为ioc,这样就会从EWeb4J的IOC容器里获取 | value: 当时type=ioc的时候填写IOC的bean_id,否则填写完整类名 | sort: 排序,同一个扩展点有多个实现类,这些实现类会以责任链的方式进行执行,因此它们的执行顺序将变得很重要 --> <impl type="" value="org.eweb4j.spiderman.plugin.impl.TaskPollPointImpl" sort="0"/> </extension> <extension point="begin"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.BeginPointImpl" sort="0"/> </extension> <extension point="fetch"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.FetchPointImpl" sort="0"/> </extension> <extension point="dig"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.DigPointImpl" sort="0"/> </extension> <extension point="dup_removal"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.DupRemovalPointImpl" sort="0"/> </extension> <extension point="task_sort"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.TaskSortPointImpl" sort="0"/> </extension> <extension point="task_push"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.TaskPushPointImpl" sort="0"/> </extension> <extension point="target"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.TargetPointImpl" sort="0"/> </extension> <extension point="parse"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.ParsePointImpl" sort="0"/> </extension> <extension point="end"> <impl type="" value="org.eweb4j.spiderman.plugin.impl.EndPointImpl" sort="0"/> </extension> </extensions> <providers> <provider> <orgnization name="CFuture" website="http://lurencun.com" desc="Color your future"> <author name="weiwei" website="http://laiweiweihi.iteye.com | http://my.oschina.net/laiweiwei" email="l.weiwei@163.com" weibo="http://weibo.com/weiweimiss" desc="一个喜欢自由、音乐、绘画的IT老男孩" /> </orgnization> </provider> </providers> </plugin> </plugins> </site> </beans>
如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

评论(7)


就是 id是要变化的
<urlRules policy="and"> <rule type="regex" value="http://app2.sfda.gov.cn/datasearchp/index1.do?tableId=25&tableName=TABLE25&tableView=葡萄糖注射液&Id=d+"> </rule> </urlRules>
发布评论
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。