定义信息源的一些示例(xml文件)
这里有一些共享的信息源,点击Download按钮下载即可。
本文目录
1、订阅博客,简单一例
2、从网页获取信息,简单一例
3、充分使用callback回调代码
4、html_re中包含多个block
5、使用html_json这个worker,解析json数据
1、订阅博客,简单一例:
<source>
<name>范志红博客</name>
<comment>搜狐博客。原创营养信息。</comment>
<link>http://snowheart19.blog.sohu.com/</link> <worker>rss_atom</worker>
<data>
<url>http://snowheart19.blog.sohu.com/rss</url>
</data>
</source>
2、从网页获取信息,简单一例:
<source>
<name>ybk168新邮预告</name>
<comment>ybk168新邮预告</comment>
<link>http://www.ybk168.com/newslist/00040051.html</link> <worker>html_re</worker>
<data>
<url>http://www.ybk168.com/newslist/00040051.html</url>
<block>
<blockre flags='DOTALL'>
<![CDATA[
<div class="list">(.*?)<div class="page">
]]>
</blockre>
<itemre flags='DOTALL'>
<![CDATA[
<li><span.*?href="([^"]+)".*?title="([^"]+)".*?
class="list_lr">([^<]+)<
]]>
</itemre>
<maprules>
<title>2</title>
<url>'http://www.ybk168.com', 1</url>
<pub_date>3</pub_date>
</maprules>
</block>
</data>
</source>
3、充分使用callback回调代码:
<source>
<name>北京空气质量</name>
<comment>北京环境监测的微博。',利有散染预【8时' in s or '浓度】' not in s</comment>
<link>http://weibo.cn/u/2516831703</link> <worker>html_re</worker>
<data>
<url>http://weibo.cn/u/2516831703</url> <block>
<blockre flags='DOTALL'>
<![CDATA[
<div class="b">(.*)$
]]>
</blockre>
<itemre flags='DOTALL'>
<![CDATA[
weibo\.cn\[([\d-]+)
]]>
</itemre>
<maprules>
<title>'notitle'</title>
<pub_date>1</pub_date>
<suid>1</suid>
</maprules>
</block> <block>
<blockre flags='DOTALL'>
<![CDATA[
^(?:.*?\[<span class="kt">置顶</span>\]|.*?<span class="pms">)
(.*?)
<input type="submit" value="查看更多内容"
]]>
</blockre>
<itemre flags='DOTALL'>
<![CDATA[
<div class="c" id="([^"]+)">
(?:<div><span class="ctt">|.*?<span class="cmt">转发理由:</span>)
(.*?)
(?:</span>|<a [^>]+>赞\[\d+\]).*?
<span class="ct">([^& ]+)
]]>
</itemre>
<maprules>
<title>'notitle'</title>
<summary>2</summary>
<pub_date>3</pub_date>
<suid>1</suid>
</maprules>
</block>
</data> <callback>
<![CDATA[
if posi == 0:
temp_date = info.pub_date
info.temp = 'del'
elif '日' in info.pub_date:
info.temp = 'del'
else:
s = info.summary
if ',' in s or \
'利' in s or \
'有' in s or \
'散' in s or \
'染' in s or \
'预' in s or \
'【8时' in s or \
'浓度】' not in s:
info.url = 'http://weibo.cn/u/2516831703'
info.pub_date = ''
info.title = '[' + temp_date + '] ' + s[:16] + '…'
else:
info.temp = 'del'
]]>
</callback>
</source>
4、html_re中包含多个block:
<source>
<name>中国国家地理</name>
<comment>中国国家地理</comment>
<link>http://www.dili360.com/</link> <worker>html_re</worker>
<data>
<url>http://www.dili360.com/</url> <block>
<blockre flags='DOTALL'>
<![CDATA[
<div class="community-item" id="community-items" >
(.*?)<!--end-->
]]>
</blockre>
<itemre flags='DOTALL'>
<![CDATA[
<li class="img-block".*?
<a target="_blank" href="([^"]+)">.*?
<h4>(.*?)</h4>
]]>
</itemre>
<maprules>
<title>2</title>
<url>'http://www.dili360.com', 1</url>
</maprules>
</block> <block>
<blockre flags='DOTALL'>
<![CDATA[
<div class="community-item" id="community-items" >
(.*?)<!--end-->
]]>
</blockre>
<itemre flags='DOTALL'>
<![CDATA[
<dt><a href="([^"]+)" target="_blank">(.*?)</a></dt>
]]>
</itemre>
<maprules>
<title>2</title>
<url>'http://www.dili360.com', 1</url>
</maprules>
</block> <block>
<blockre flags='DOTALL'>
<![CDATA[
<ul class="style-1" id="replace">(.*?)</ul>
]]>
</blockre>
<itemre flags='DOTALL'>
<![CDATA[
<div class="detail">.*?
<a href="([^"]+)" target="_blank"><h4>(.*?)</h4>
]]>
</itemre>
<maprules>
<title>2</title>
<url>'http://www.dili360.com', 1</url>
<summary>'景观图片'</summary>
</maprules>
</block> </data>
</source>
5、使用html_json这个worker,解析json数据:
<source>
<name>新浪书讯</name>
<comment>新浪图书,书讯。</comment>
<link>http://book.sina.com.cn/</link> <worker>html_json</worker>
<data>
<url>http://feed.mix.sina.com.cn/api/roll/get?callback=jsonp1436772833418&pageid=8&lid=156&num=20</url>
<re flags='DOTALL'>
<![CDATA[
^try\{\w+\(
(.*)
\);\}catch\(e\)\{\};$
]]>
</re> <block>
<block_path>'result', 'data'</block_path>
<title>'title'</title>
<url>'url'</url>
<summary>'summary'</summary>
<temp>'intro'</temp>
<pub_date>'ctime'</pub_date>
</block>
</data> <callback>
<![CDATA[
info.pub_date = unixtime(info.pub_date)
info.summary = info.summary or info.temp
info.temp = 0
]]>
</callback>
</source>
定义信息源的一些示例(xml文件)的更多相关文章
- 通过Bag一对多映射示例(使用xml文件)
如果持久化类具有包含实体引用的列表对象,则需要使用一对多关联来映射列表元素. 我们可以通过列表(list)或包(bag)来映射这个列表对象. 请注意,bag不是基于索引的,而list是基于索引的. 在 ...
- ACEXML解析XML文件——我是如何学习并在短时间内掌握一个库的使用方法的
最近做的C++项目中需要使用xml文件保存一些信息,程序启动时会读取这些信息.最终经过主程的评测,决定使用ACEXML库来读取解析XML文件. 好吧,至于为什么选择ACEXML库,我就不说了.既然选择 ...
- 集合映射Set(使用xml文件)
如果持久类具有Set对象,可以在映射文件中使用set元素映射Set集合. set元素不需要索引元素. List和Set之间的区别是: Set只存储唯一的值. 我们来看看我们如何在映射文件中实现集合: ...
- 集合映射中的映射包(使用xml文件)
如果持久类有List对象,我们可以通过列表或者bag元素在映射文件中映射. 这个包(bag)就像List一样,但它不需要索引元素. 在这里,我们使用论坛的场景: 论坛中一个问题有多个答案. 我们来看看 ...
- 集合映射中的映射列表(使用xml文件)
如果持久化类具有List对象,我们可以通过映射文件中的类的<list>元素或注释来映射List. 在这里,我们正在使用论坛的场景,其中一个问题有多个答案. 在这里,我们使用论坛的场景,其中 ...
- Java Web的web.xml文件作用及基本配置(转)
其实web.xml就是asp.net的web.config一个道理. 说明: 一个web中完全可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. web.xml文件是用来 ...
- web.xml 文件配置01
web.xml 文件配置01 前言:一般的web工程中都会用到web.xml,方便开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web. ...
- web.xml文件的作用
每个javaEE工程中都有web.xml文件,那么它的作用是什么呢?它是每个web.xml工程都必须的吗? 一个web中可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. ...
- [转] web.xml文件详解
转自:http://www.cnblogs.com/hellojava/archive/2012/12/28/2835730.html 前言:一般的web工程中都会用到web.xml,web.xml主 ...
随机推荐
- Unity 几种碰撞模式
1.OnControllerColliderHit 事件 (角色控制器使用) 2.Physics.Raycast 函数 3.OnTriggerEnter 事件 (碰撞物体使用,给碰撞物体添加碰撞器, ...
- 解决MySQL数据库不允许从远程访问的方法
授权法.例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话. mysql>GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' ...
- 对象序列化到本地文件 ObjectOutputstream ObjcetInputstream
package com.main.test; import java.io.FileInputStream; import java.io.FileNotFoundException; import ...
- C#为什么不采用多继承:
C#为什么不采用多继承: 1.继承从来未被广泛使用. 2.多继承带来的问题往往多于其解决的问题. 3.多继承会引起潜在的歧义. C#核心编程
- how-to-add-global-asp-net-web-api-filters
要实现给mvc 和api 接口全局添加日志统计,web api添加的方式有些不同 FilterConfig.cs 页面 public class FilterConfig { public stati ...
- JS总结 运算符 条件语句
算术运算符+-*/ 与数学计算一致,配合()号进行各种计算 另外,+号还可以达到连接的作用.例如: var a = 15; alert("a的值等于"+a); 前后增减量运算符: ...
- ACCESS --第一章
一.ACCESS2007的安装 装完整版的office2007办公软件就集成了相应的ACCESS2007 二.主要组成 ACCESS由表.查询.报表.窗体.页.宏和模块组成 1.表 表是存储数据的对象 ...
- SQL注入的字符串连接函数
在select数据时,我们往往需要将数据进行连接后进行回显.很多的时候想将多个数据或者多行数据进行输出的时候,需要使用字符串连接函数.在sqli中,常见的字符串连接函数有concat(),group_ ...
- Prime Ring Problem
Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ... ...
- 小学生四则运算出题程序 无操作界面java版 简单的运用java中一些基本操作
这是本学期java课中实验大纲里的第一个实验,这里简单做了一个无用户界面版本. import java.util.Random; import java.util.Scanner; public cl ...