Example #1
0
 def mailsubject(self):
   p = Parser()
   p.feed(self._imp)
   p.goahead(0)
   div = p.find('div', attrs={'class':'moji'})
   #FIXME assuming BeautifulSoup uses utf8
   return str(div.contents[0]).decode('utf8')
Example #2
0
 def mailbody(self):
   p = Parser()
   p.feed(self._imp)
   p.goahead(0)
   td = p.find('td', attrs={'class':'moji'})
   #FIXME assuming BeautifulSoup uses utf8
   u = str(td).decode('utf8')
   return tagStrip.sub(replproc, u)
Example #3
0
  def get(self, url, now=None):
    #ym=2009.3
    #vmode=itiran
    if now is None:
      now = dt.now()
    tomorrow = now + delta(1)

    option = urllib.urlencode(dict(
          ym='%i.%i'%(now.year, now.month),
          vmode='itiran'
          ))
    url += '?' + option
    self.write('getting feed from "%s".\n'%(url))

    p = Parser()
    f = urllib.urlopen(url)
    try:
      p.feed(f.read().decode('Shift-JIS'))
      p.goahead(0)
    finally:
      f.close()

    pages = []
    for a in p.findAll('a', attrs=dict(href="javaScript:void(0)")):
      m = parseOnClick.search(a['onclick'])
      if m:
        d = m.groupdict()
        #print d['year'], d['month'], d['day'], d['id']
        memo = '''http://www.backgammon.gr.jp/EventSchedule/calendar/calendar.cgi'''
        if int(d['day']) == tomorrow.day:
          option = urllib.urlencode(dict(
              action='memo',
              yy=d['year'],
              mm=d['month'],
              dd=d['day'],
              id=d['id'],
              ))
          f = urllib.urlopen(memo + '?' + option)
          try:
            uhtml = f.read().decode('Shift-JIS')
          finally:
            f.close()
          pages.append(Item(self, uhtml))
    return pages