Commit 7f1849bd authored by Romain Courteaud's avatar Romain Courteaud

Split download/parsing of RSS data in 2 functions.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27777 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 997485c9
from urllib2 import HTTPPasswordMgrWithDefaultRealm, HTTPBasicAuthHandler, \
build_opener, install_opener, urlopen, HTTPError
from xml.dom.minidom import parse
from xml.dom.minidom import parseString
import md5
from HTMLParser import HTMLParser
......@@ -24,8 +24,11 @@ def getRssDataAsDict(url, username, password):
return {'title': 'Page not found.' }
except :
return {'title': 'Fetching Rss failed.' }
return parseRssDataAsDict(file.read())
def parseRssDataAsDict(rss_string):
try:
xmlDoc = parse(file).documentElement
xmlDoc = parseString(rss_string).documentElement
except :
return {'title': 'Parsing RSS failed.' }
if(xmlDoc.tagName.startswith('rss') or xmlDoc.tagName.startswith('rdf') ):
......
395
\ No newline at end of file
402
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment