I've come up with this python code that is supposed to take a text file with thousands of RSS urls (one per line) and create one XML file PER 500 lines.
Here is what I have so far:
urls = open('file.txt','r').read().splitlines()
opml = open('opml.xml','w')
opml.write('<?xml version="1.0" encoding="UTF-8"?>\n<opml version="1.0">\n<head>\n<title>My Rss list</title>\n</head>\n<body>\n')
for i in xrange(500):
opml.write('<outline title="RSS Site %d" type="rss" xmlUrl = "%s"/>\n'%(i + 1, urls[i]))
opml.write('</body>\n</opml>')
opml.close()
But it's got problems, the result file ends up looking like this:
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>My Rss list</title>
</head>
<body>
It is missing the closing body and the closing opml, and obviously it's missing the outline bits.
In the python shell, when I run the script I get this error:
Traceback (most recent call last): File "C:/Users/nzbit/Desktop/Convert To OPML Python Test/converttoopml.py", line 6, in <module> for i in xrange(500): NameError: name 'xrange' is not defined
UPDATE: Here is the latest issue in the produced XML files:
<outline title="RSS Site 1" type="rss" xmlUrl = "��tp://www.gardenleisurepools.com/forum/external?type=rss2"/>
<outline title="RSS Site 2" type="rss" xmlUrl = ""/>
<outline title="RSS Site 3" type="rss" xmlUrl = "http://www.meguiarsonline.com/forum/external.php?type=RSS2"/>
<outline title="RSS Site 4" type="rss" xmlUrl = ""/>
<outline title="RSS Site 5" type="rss" xmlUrl = "http://www.newportri.com/board/external?type=rss2"/>
<outline title="RSS Site 6" type="rss" xmlUrl = ""/>
<outline title="RSS Site 7" type="rss" xmlUrl = "http://www.abandonware-forums.org/forums/external?type=rss2"/>
<outline title="RSS Site 8" type="rss" xmlUrl = ""/>
<outline title="RSS Site 9" type="rss" xmlUrl = "https://www.lrcsite.com/forum/external.php?type=RSS2"/>
<outline title="RSS Site 10" type="rss" xmlUrl = ""/>
<outline title="RSS Site 11" type="rss" xmlUrl = "http://www.accutane-recall.com/forums/external?type=rss2"/>