-
Notifications
You must be signed in to change notification settings - Fork 19
/
snsearch.py
26 lines (21 loc) · 999 Bytes
/
snsearch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-
__author__ = 'Sagacity'
import urllib
import xml.dom.minidom
theQuery = u"{query}"
# theQuery = u"io"
theQuery = theQuery.strip().lower()
rssurl = 'http://news.dbanotes.net/rss'
urldoc = xml.dom.minidom.parse( urllib.urlopen( rssurl ) )
print "<?xml version=\"1.0\"?>\n<items>"
for item in urldoc.getElementsByTagName('item'):
title = item.getElementsByTagName('title')[0].firstChild.data.replace( "&", "##" )
link = item.getElementsByTagName('link')[0].firstChild.data.replace( "&", "%26" )
comments = item.getElementsByTagName('comments')[0].firstChild.data.replace( "&", "%26" )
if (theQuery in title.lower()) or theQuery == "all":
print " <item uid=\"SN\" arg=\""+ link + "|" + comments + "\">"
print " <title>" + title.encode('utf-8') + "</title>"
print " <subtitle>" + comments + "</subtitle>"
print ''' <icon type="fileicon">/Applications/Safari.app/</icon>
</item>'''
print "</items>\n"