parent
186fa2b408
commit
6ce616106b
|
@ -1,76 +1,73 @@
|
||||||
[rss]
|
[rss-rdf]
|
||||||
mode = xpath
|
mode = xml
|
||||||
|
|
||||||
;RSS, rdf:rdf
|
timeformat = %a, %d %b %Y %H:%M:%S %Z
|
||||||
;RSS, channel
|
|
||||||
;Atom
|
|
||||||
;Atom 03
|
|
||||||
|
|
||||||
timeformat =
|
base = <?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"></rdf:RDF>
|
||||||
%a, %d %b %Y %H:%M:%S %Z
|
|
||||||
%a, %d %b %Y %H:%M:%S %Z
|
|
||||||
%Y-%m-%dT%H:%M:%SZ
|
|
||||||
%Y-%m-%dT%H:%M:%SZ
|
|
||||||
|
|
||||||
base =
|
title = /rdf:RDF/rssfake:channel/rssfake:title
|
||||||
<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"></rdf:RDF>
|
desc = /rdf:RDF/rssfake:channel/rssfake:description
|
||||||
<?xml version="1.0"?><rss version="2.0"></rss>
|
items = /rdf:RDF/rssfake:channel/rssfake:item
|
||||||
<?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"></feed>
|
|
||||||
<?xml version="1.0"?><feed version="0.3" xmlns="http://purl.org/atom/ns#"></feed>
|
|
||||||
|
|
||||||
title =
|
item_title = rssfake:title
|
||||||
/rdf:RDF/rssfake:channel/rssfake:title
|
item_link = rssfake:link
|
||||||
/rss/channel/title
|
item_desc = rssfake:description
|
||||||
/atom:feed/atom:title
|
item_content = content:encoded
|
||||||
/atom03:feed/atom03:title
|
item_time = rssfake:pubDate
|
||||||
|
|
||||||
desc =
|
|
||||||
/rdf:RDF/rssfake:channel/rssfake:description
|
|
||||||
/rss/channel/description
|
|
||||||
/atom:feed/atom:subtitle
|
|
||||||
/atom03:feed/atom03:subtitle
|
|
||||||
|
|
||||||
items =
|
[rss-channel]
|
||||||
/rdf:RDF/rssfake:channel/rssfake:item
|
mode = xml
|
||||||
/rss/channel/item
|
|
||||||
/atom:feed/atom:entry
|
|
||||||
/atom03:feed/atom03:entry
|
|
||||||
|
|
||||||
item_title =
|
timeformat = %a, %d %b %Y %H:%M:%S %Z
|
||||||
rssfake:title
|
|
||||||
title
|
|
||||||
atom:title
|
|
||||||
atom03:title
|
|
||||||
|
|
||||||
item_link =
|
base = <?xml version="1.0"?><rss version="2.0"></rss>
|
||||||
rssfake:link
|
|
||||||
link
|
|
||||||
atom:link/@href
|
|
||||||
atom03:link/@href
|
|
||||||
|
|
||||||
item_desc =
|
title = /rss/channel/title
|
||||||
rssfake:description
|
desc = /rss/channel/description
|
||||||
description
|
items = /rss/channel/item
|
||||||
atom:summary
|
|
||||||
atom03:summary
|
|
||||||
|
|
||||||
item_content =
|
item_title = title
|
||||||
content:encoded
|
item_link = link
|
||||||
content:encoded
|
item_desc = description
|
||||||
atom:content
|
item_content = content:encoded
|
||||||
atom03:content
|
item_time = pubDate
|
||||||
|
|
||||||
item_time =
|
|
||||||
rssfake:pubDate
|
|
||||||
pubDate
|
|
||||||
atom:published
|
|
||||||
atom03:published
|
|
||||||
|
|
||||||
item_updated =
|
[rss-atom]
|
||||||
; N/A
|
mode = xml
|
||||||
; N/A
|
|
||||||
atom:updated
|
timeformat = %Y-%m-%dT%H:%M:%SZ
|
||||||
atom03:updated
|
|
||||||
|
base = <?xml version="1.0"?><feed xmlns="http://www.w3.org/2005/Atom"></feed>
|
||||||
|
|
||||||
|
title = /atom:feed/atom:title
|
||||||
|
desc = /atom:feed/atom:subtitle
|
||||||
|
items = /atom:feed/atom:entry
|
||||||
|
|
||||||
|
item_title = atom:title
|
||||||
|
item_link = atom:link/@href
|
||||||
|
item_desc = atom:summary
|
||||||
|
item_content = atom:content
|
||||||
|
item_time = atom:published
|
||||||
|
item_updated = atom:updated
|
||||||
|
|
||||||
|
[rss-atom03]
|
||||||
|
mode = xml
|
||||||
|
|
||||||
|
timeformat = %Y-%m-%dT%H:%M:%SZ
|
||||||
|
|
||||||
|
base = <?xml version="1.0"?><feed version="0.3" xmlns="http://purl.org/atom/ns#"></feed>
|
||||||
|
title = /atom03:feed/atom03:title
|
||||||
|
desc = /atom03:feed/atom03:subtitle
|
||||||
|
items = /atom03:feed/atom03:entry
|
||||||
|
|
||||||
|
item_title = atom03:title
|
||||||
|
item_link = atom03:link/@href
|
||||||
|
item_desc = atom03:summary
|
||||||
|
item_content = atom03:content
|
||||||
|
item_time = atom03:published
|
||||||
|
item_updated = atom03:updated
|
||||||
|
|
||||||
[json]
|
[json]
|
||||||
mode = json
|
mode = json
|
||||||
|
|
|
@ -67,31 +67,11 @@ class ParserBase(object):
|
||||||
self.rules = rules
|
self.rules = rules
|
||||||
|
|
||||||
if data is None:
|
if data is None:
|
||||||
if isinstance(self.rules['items'], list):
|
|
||||||
data = rules['base'][0]
|
|
||||||
|
|
||||||
else:
|
|
||||||
data = rules['base']
|
data = rules['base']
|
||||||
|
|
||||||
self.root = self.parse(data)
|
self.root = self.parse(data)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
|
||||||
# do `if multi` and select the correct rule for each (and split \n)
|
|
||||||
if isinstance(self.rules['items'], list):
|
|
||||||
for (i, rule) in enumerate(self.rules['items']):
|
|
||||||
if self.rule_search(rule) is not None:
|
|
||||||
key = i
|
|
||||||
break
|
|
||||||
|
|
||||||
else:
|
|
||||||
key = 0
|
|
||||||
|
|
||||||
len_items = len(rules['items'])
|
|
||||||
|
|
||||||
for arg in self.rules.keys():
|
|
||||||
if (isinstance(self.rules[arg], list)
|
|
||||||
and len(self.rules[arg]) == len_items):
|
|
||||||
self.rules[arg] = self.rules[arg][key]
|
|
||||||
|
|
||||||
def parse(self, raw):
|
def parse(self, raw):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue