Exemplo n.º 1
0
    def do_GET(self):
        global need_refresh
        global rss
        global items
        global signals

        #self.send_error(404)

        if need_refresh:
            need_refresh = False
            url = config.get('Socialtext', 'Host')
            if config.getboolean('Socialtext', 'Secure'):
                url = 'https://' + url
            else:
                url = 'http://' + url

            rss_data = {
                'title': 'Socialtext Signals',
                'version': '2.0',
                'description': 'Socialtext signal updates',
                'link': url,

                'item': signals
            }
            d2r = dict2rss(rss_data)
            d2r.PrettyPrint()
            rss = d2r.output()
        self.send_response(200)
        self.send_header('Content-Type', 'application/xml')
        self.end_headers()
        self.wfile.write(rss.encode('utf8'))
Exemplo n.º 2
0
    def get(self):
        mapUrlPattern = 'http://maps.googleapis.com/maps/api/staticmap?sensor=false&center=%s&zoom=13&size=600x300&maptype=roadmap&markers=color:blue|label:S|%s'

        # /feeds/Aanbod.svc/rss/?type=koop&zo=/amsterdam/0-200000/60+woonopp/3+kamers/
        targetUrl = 'http://partnerapi.funda.nl' + self.request.path_qs

        feed = feedparser.parse(urllib2.urlopen(targetUrl))

        convertedEntries = {}
        for e in feed['entries']:
            address = e.title.replace('Te koop:', '')
            address = re.sub(r'\s?\+\s+PP\s?', '', address)
            convertedEntries[e.title] = {
                'title':
                e.title,
                'link':
                e.link,
                'description':
                e.summary + '<img src="%s" title="Map"/>' %
                (mapUrlPattern % (address, address)),
            }
        my_feed_data = {
            'title': 'My feed',
            'item': convertedEntries,
            'version': '0.1',
        }

        d = dict2rss.dict2rss(my_feed_data)

        self.response.headers['Content-Type'] = 'application/xml'
        self.response.out.write(d._out())
Exemplo n.º 3
0
    def get(self):
        mapUrlPattern = 'http://maps.googleapis.com/maps/api/staticmap?sensor=false&center=%s&zoom=13&size=600x300&maptype=roadmap&markers=color:blue|label:S|%s'

        # /feeds/Aanbod.svc/rss/?type=koop&zo=/amsterdam/0-200000/60+woonopp/3+kamers/
        targetUrl = 'http://partnerapi.funda.nl' + self.request.path_qs

        feed = feedparser.parse(urllib2.urlopen(targetUrl))

        convertedEntries = {}
        for e in feed['entries']:
            address = e.title.replace('Te koop:', '')
            address = re.sub(r'\s?\+\s+PP\s?', '', address)
            convertedEntries[e.title] = {
                'title': e.title,
                'link': e.link,
                'description': e.summary + '<img src="%s" title="Map"/>' % (mapUrlPattern % (address, address)),
            }
        my_feed_data = {
            'title': 'My feed',
            'item': convertedEntries,
            'version':'0.1',
        }

        d = dict2rss.dict2rss(my_feed_data)

        self.response.headers['Content-Type'] = 'application/xml'
        self.response.out.write(d._out())
Exemplo n.º 4
0
#      print("   attr: ", name, value)
    if tag == 'div':
      for name, value in attrs:
        if name == "class" and value == "name":
          self.printing = 1 
    if tag == 'a':
      for name, value in attrs:
        if name == "href" and value.startswith('/movies'):
          self.href = "http://www.google.com" + value
  def handle_data(self, data):
    if self.printing == 1:
      movies['item'][data] = {}
      movies['item'][data]['description'] = data
      movies['item'][data]['content'] = self.href
      self.printing = 0

p = parser()

#print(sock.info())
html = codecs.decode(sock.read())
#print(len(html))
fixed = string.replace(html, '"onresize', '" onresize')
p.feed(fixed)
p.close()
sock.close()

#print(movies)

rss = dict2rss(movies)
rss.PrettyPrint()
Exemplo n.º 5
0
import sys
import dict2rss
sys.path.insert(0, 'feedparser')


import urllib
import feedparser

mapUrlPattern = 'http://maps.googleapis.com/maps/api/staticmap?sensor=false&center=%s&zoom=13&size=600x300&maptype=roadmap&markers=color:blue|label:S|%s'

targetUrl = 'http://partnerapi.funda.nl/feeds/Aanbod.svc/rss/?type=koop&zo=/amsterdam/0-200000/60+woonopp/3+kamers/'

feed = feedparser.parse(urllib.urlopen(targetUrl))

convertedEntries = {}
for e in feed['entries']: 
    address = e.title.replace('Te koop:', '')
    convertedEntries[e.title] = {
        'title': e.title,
        'description': e.summary + '<img src="%s" title="Map"/>' % (mapUrlPattern % (address, address)),
    }
my_feed_data = {
    'title': 'My feed',
    'item': convertedEntries,
    'version':'0.1',
}

d = dict2rss.dict2rss(my_feed_data)
d.PrettyPrint()

Exemplo n.º 6
0
            for name, value in attrs:
                if name == "class" and value == "name":
                    self.printing = 1
        if tag == 'a':
            for name, value in attrs:
                if name == "href" and value.startswith('/movies'):
                    self.href = "http://www.google.com" + value

    def handle_data(self, data):
        if self.printing == 1:
            movies['item'][data] = {}
            movies['item'][data]['description'] = data
            movies['item'][data]['content'] = self.href
            self.printing = 0


p = parser()

#print(sock.info())
html = codecs.decode(sock.read())
#print(len(html))
fixed = string.replace(html, '"onresize', '" onresize')
p.feed(fixed)
p.close()
sock.close()

#print(movies)

rss = dict2rss(movies)
rss.PrettyPrint()