Ejemplo n.º 1
0
    def ipinfo(self):
        web = Web()
        uri = 'http://whatismyipaddress.com/ip/'
        try:
            answer = web.html(web.get(uri + self.args[0]))

            if answer:
                th = answer.findAll('th')
                td = answer.findAll('td')

                infos = []
                for x in range(len(td)):
                    key = th[x].string.lower().strip()
                    value = re.sub(
                        '\([^()]+\)', '',
                        re.sub('<[^<>]*>', '',
                               str(td[x])).strip('\n').replace('&nbsp;',
                                                               '').strip())
                    if not value.startswith('None') and len(value):
                        infos.append("%s %s" % (key, value))
            else:
                return False
        except:
            return False

        if len(infos):
            self.parent.conn.privmsg(self.channel, ', '.join(infos))
Ejemplo n.º 2
0
 def btc(self):
     web = Web()
     try:
         answer = web.html(web.get('http://bitcoinexchangerate.org/c/USD/1'))
         pattern = re.compile('([0-9.]+)')
         result = re.findall(pattern, str(answer.title.string))[0]
         self.parent.conn.privmsg(self.channel, "%s USD / BTC" % round(float(result), 2))
     except:
         return False
Ejemplo n.º 3
0
    def cotacao(self):
        url = 'http://economia.uol.com.br/cotacoes'
        web = Web()
        response = web.html(web.get(url))
        result = []
        infos = {}

        if len(self.args) < 1:
            exchange = None
        else:
            exchange = self.args[0]

        regex = {
            'dolar turismo':
            [r'(d.lar\stur.)\n.ompra\s+(?P<compra>.+)\n.enda\s+(?P<venda>.+)'],
            'dolar comercial': [
                r'(d.lar\scom.)\n.ompra\s+(?P<compra>.+)\n.enda\s+(?P<venda>.+)',
                r'(d.lar\s.omercial)\n(?P<compra>.+)\n(?P<venda>.+)'
            ],
            'euro': [
                r'(euro)\n.ompra\s+(?P<compra>.+)\n.enda\s+(?P<venda>.+)',
                r'(euro)\n(?P<compra>.+)\n(?P<venda>.+)'
            ],
            'libra': [
                r'(libra)\n.ompra\s+(?P<compra>.+)\n.enda\s+(?P<venda>.+)',
                r'(libra)\n(?P<compra>.+)\n(?P<venda>.+)'
            ],
        }

        if response:
            try:
                for k, v in regex.iteritems():
                    for l in v:
                        r = re.compile(l, re.I).search(response.text)
                        if not isinstance(r, types.NoneType):
                            if k not in infos:
                                infos[k] = "compra = %s, venda = %s" % (
                                    r.group(2).replace(',', '.'),
                                    r.group(3).replace(',', '.'))

                if exchange:
                    for k, v in infos.iteritems():
                        if exchange in k:
                            result.append("%s: %s, " % (k, v))
                else:
                    for k, v in infos.iteritems():
                        result.append("%s: %s, " % (k, v))

                if result:
                    result.append('fonte: %s' % url.split('/')[2])
                    self.parent.conn.privmsg(
                        self.channel, '%s, %s' % (self.nick, ''.join(result)))
            except:
                return False
Ejemplo n.º 4
0
 def transito(self):
     web = Web()
     answer = web.html(web.get('http://cetsp1.cetsp.com.br/monitransmapa/agora/'))
     if answer:
         dados = {
             'hora': answer.find('div', id="hora").findAll(text=True)[0],
             'lentidao': answer.find('div', id="lentidao").findAll(text=True)[0],
         }
         result = "%(lentidao)s km de transito, atualizado as %(hora)s" % dados
         self.parent.conn.privmsg(self.channel, result)
     else:
         return False
Ejemplo n.º 5
0
    def transito(self):
        web = Web()
        answer = web.html(web.get('http://cetsp1.cetsp.com.br/monitransmapa/agora/'))
        if answer:
            dados = {
                'hora': answer.find('div', id="hora").findAll(text=True)[0],
                'lentidao': answer.find('div', id="lentidao").findAll(text=True)[0],
            }
            result = "%(lentidao)s km de transito em SP, atualizado as %(hora)s" % dados
            self.parent.conn.privmsg(self.channel, result)
            self.parent.conn.privmsg(self.channel, '%s' % ('Quer o transito de BH? www.maplink.com.br/MG/belo_horizonte/TransitoAgora '))

        else:
            return False
Ejemplo n.º 6
0
    def dic(self):
	if len(self.args) < 1:
		self.parent.conn.privmsg(self.channel, '%s' % ('Digite a palavra que gostaria de procurar'))
	else:
		web = Web()
		answer = web.html(web.get('http://michaelis.uol.com.br/moderno/portugues/index.php?lingua=portugues-portugues&palavra='+self.args[0]))
		if answer:
			dados = {
				'significado': answer.find('div', id="descricao").findAll(text=True)[0],
			}
			result = "Significado: %(significado)s " % dados
			self.parent.conn.privmsg(self.channel, result)
		else:
		    return False
Ejemplo n.º 7
0
    def dollar(self):
        url = 'http://www4.bcb.gov.br/feed/taxas.ashx'
        web = Web()
        result = web.xml(web.get(url))

        if result:

            for element in result.getElementsByTagName("item"):
                title = self.get_text(element.getElementsByTagName("title")[0].childNodes)
                description = self.get_text(element.getElementsByTagName("description")[0].childNodes)
                if str(title).endswith('EUA'):
                    data = "%s %s" % (title, ' '.join(web.html(description).findAll('div', id='value', text=True)))

            data += ', fonte: www.bcb.gov.br'
            self.parent.conn.privmsg(self.channel, '%s, %s' % (self.nick, data.lower().replace('&agrave;', 'à')))
Ejemplo n.º 8
0
    def dollar(self):
        url = "http://www4.bcb.gov.br/feed/taxas.ashx"
        web = Web()
        result = web.xml(web.get(url))

        if result:

            for element in result.getElementsByTagName("item"):
                title = self.get_text(element.getElementsByTagName("title")[0].childNodes)
                description = self.get_text(element.getElementsByTagName("description")[0].childNodes)
                if str(title).endswith("EUA"):
                    data = "%s %s" % (title, " ".join(web.html(description).findAll("div", id="value", text=True)))

            data += ", fonte: www.bcb.gov.br"
            self.parent.conn.privmsg(self.channel, "%s, %s" % (self.nick, data.lower().replace("&agrave;", "à")))
Ejemplo n.º 9
0
def ipinfo(args):
    try:
        web = Web()
        uri = 'http://whatismyipaddress.com/ip/'
        answer = web.html(web.get(uri + args))
        return answer

        th = answer.findAll('th')
        td = answer.findAll('td')

        infos = []
        for x in range(len(td)):
            key = th[x].string.lower().strip()
            value = re.sub('\([^()]+\)', '', re.sub('<[^<>]*>', '', str(td[x])).strip('\n').replace('&nbsp;', '').strip())
            if not value.startswith('None') and len(value):
                infos.append("%s %s" % (key, value))
        return ', '.join(infos)
    except Exception, e:
        return repr(e)
Ejemplo n.º 10
0
 def dic(self):
     if len(self.args) < 1:
         self.parent.conn.privmsg(
             self.channel,
             '%s' % ('Digite a palavra que gostaria de procurar'))
     else:
         web = Web()
         answer = web.html(
             web.get(
                 'http://michaelis.uol.com.br/moderno/portugues/index.php?lingua=portugues-portugues&palavra='
                 + self.args[0]))
         if answer:
             dados = {
                 'significado':
                 answer.find('div', id="descricao").findAll(text=True)[0],
             }
             result = "Significado: %(significado)s " % dados
             self.parent.conn.privmsg(self.channel, result)
         else:
             return False
Ejemplo n.º 11
0
    def ipinfo(self):
        web = Web()
        uri = 'http://whatismyipaddress.com/ip/'
        answer = web.html(web.get(uri + self.args[0]))

        if answer:
            th = answer.findAll('th')
            td = answer.findAll('td')

            infos = []
            for x in range(len(td)):
                key = th[x].string.lower().strip()
                value = str(html.fromstring(str(td[x]).replace('\n', '')).text).strip()
                if not value.startswith('None'):
                    infos.append("%s %s" % (key, value))
        else:
            return False

        if len(infos):
            self.parent.conn.privmsg(self.channel, ', '.join(infos))
Ejemplo n.º 12
0
    def transito(self):
        web = Web()
        answer = web.html(
            web.get('http://cetsp1.cetsp.com.br/monitransmapa/agora/'))
        if answer:
            dados = {
                'hora':
                answer.find('div', id="hora").findAll(text=True)[0],
                'lentidao':
                answer.find('div', id="lentidao").findAll(text=True)[0],
            }
            result = "%(lentidao)s km de transito em SP, atualizado as %(hora)s" % dados
            self.parent.conn.privmsg(self.channel, result)
            self.parent.conn.privmsg(
                self.channel, '%s' %
                ('Quer o transito de BH? www.maplink.com.br/MG/belo_horizonte/TransitoAgora '
                 ))

        else:
            return False
Ejemplo n.º 13
0
    def ipinfo(self):
        web = Web()
        uri = 'http://ip.nixdns.com.br/plain/'
        answer = web.html(web.get(uri + self.args[0]))

        if answer:
            th = answer.findAll('th')
            td = answer.findAll('td')

            infos = []
            for x in range(len(td)):
                key = th[x].string.lower().strip()
                value = str(html.fromstring(str(td[x]).replace('\n', '')).text).strip()
                if not value.startswith('None'):
                    infos.append("%s %s" % (key, value))
        else:
            return False

        if len(infos):
            self.parent.conn.privmsg(self.channel, ', '.join(infos))
Ejemplo n.º 14
0
def ipinfo(args):
    try:
        web = Web()
        uri = 'http://whatismyipaddress.com/ip/'
        answer = web.html(web.get(uri + args))
        return answer

        th = answer.findAll('th')
        td = answer.findAll('td')

        infos = []
        for x in range(len(td)):
            key = th[x].string.lower().strip()
            value = re.sub(
                '\([^()]+\)', '',
                re.sub('<[^<>]*>', '',
                       str(td[x])).strip('\n').replace('&nbsp;', '').strip())
            if not value.startswith('None') and len(value):
                infos.append("%s %s" % (key, value))
        return ', '.join(infos)
    except Exception, e:
        return repr(e)
Ejemplo n.º 15
0
    def ipinfo(self):
        web = Web()
        uri = 'http://whatismyipaddress.com/ip/'
        try:
            answer = web.html(web.get(uri + self.args[0]))

            if answer:
                th = answer.findAll('th')
                td = answer.findAll('td')

                infos = []
                for x in range(len(td)):
                    key = th[x].string.lower().strip()
                    value = re.sub('\([^()]+\)', '', re.sub('<[^<>]*>', '', str(td[x])).strip('\n').replace('&nbsp;', '').strip())
                    if not value.startswith('None') and len(value):
                        infos.append("%s %s" % (key, value))
            else:
                return False
        except:
            return False

        if len(infos):
            self.parent.conn.privmsg(self.channel, ', '.join(infos))