Esempio n. 1
0
def search(query):
    channels = {}
    source = httplib.get_source('http://irc.netsplit.de/channels/?chat=' +
                                query.replace(' ', '+'))
    for i in ('&#8203;', '<b>', '</b>', '<span style="color:#000000;">',
              '<strong>', '</strong>'):
        source = source.replace(i, '')
    channel_objects = re.findall(
        '<div style="margin: 4px; padding: 0 0 15 0; text-align: left;">(.*?)</a></span></div>',
        source, re.IGNORECASE | re.MULTILINE)
    for data in channel_objects:
        channel = functions.between(data, '<span class="cs-channel">',
                                    '</span>')
        network = functions.between(data, '<span class="cs-network">',
                                    '</span>')
        users = functions.between(data, '<span class="cs-users">',
                                  ' &ndash; </span>')
        topic = functions.between(data, '<span class="cs-topic">',
                                  '</span><br>')
        if not topic:
            topic = 'No channel topic set.'
        channels[channel] = {
            'network': network,
            'users': users,
            'topic': topic
        }
    return channels
Esempio n. 2
0
def define(word):
	source  = httplib.get_source('http://www.merriam-webster.com/dictionary/' + word.replace(' ', '%20'))
	results = functions.between(source, f'<meta name="description" content="Define {word}: ', '">')
	if results:
		return results
	else:
		return False
Esempio n. 3
0
def define(word):
    source = httplib.get_source('http://www.merriam-webster.com/dictionary/' +
                                word.replace(' ', '%20'))
    results = functions.between(
        source, f'<meta name="description" content="Define {word}: ', '">')
    if results:
        return results
    else:
        return False
Esempio n. 4
0
def check(url):
    source = httplib.get_source('http://isup.me/' + url)
    if source.find('It\'s just you.') != -1:
        return 'UP'
    elif source.find('It\'s not just you!') != -1:
        return 'DOWN'
    elif source.find('Huh?') != -1:
        return 'INVALID'
    else:
        return 'UNKNOWN'
Esempio n. 5
0
def search(query, results):
	url      = 'https://thepiratebay.org/search/{0}/0/99/0'.format(query.replace(' ', '+'))
	source   = httplib.get_source(url)
	torrents = re.findall('<a href="(.*?)" class="detLink".*>(.*?)</a>', source)
	seeders  = re.findall('\t\t</td>\n\t\t<td align="right">(.*?)</td>', source)
	leechers = re.findall('<td align="right">(.*?)</td>\n\t</tr>',       source)
	if torrents:
		data     = {}
		torrents = torrents[:results]
		for i in range(len(torrents)):
			data[torrents[i][1]] = {'seeders':seeders[i], 'leechers':leechers[i], 'url':torrents[i][0]}
		return data
	else:
	   return False
Esempio n. 6
0
def ask(query):
	params  = httplib.data_encode({'input':query, 'appid':config.api.wolfram_api_key})
	data    = httplib.get_source('http://api.wolframalpha.com/v2/query?' + params)
	results = {}
	tree	= etree.fromstring(data)
	for e in tree.findall('pod'):
		for item in [ef for ef in list(e) if ef.tag=='subpod']:
			for it in [i for i in list(item) if i.tag=='plaintext']:
				if it.tag=='plaintext':
					results[e.get('title')] = it.text
	if 'Result' in results:
		return results['Result']
	else:
		return False
Esempio n. 7
0
def search(query):
	channels = {}
	source   = httplib.get_source('http://irc.netsplit.de/channels/?chat=' + query.replace(' ','+'))
	for i in ('&#8203;','<b>','</b>','<span style="color:#000000;">','<strong>','</strong>'):
		source = source.replace(i, '')
	channel_objects = re.findall('<div style="margin: 4px; padding: 0 0 15 0; text-align: left;">(.*?)</a></span></div>', source, re.IGNORECASE|re.MULTILINE)
	for data in channel_objects:
		channel = functions.between(data, '<span class="cs-channel">', '</span>')
		network = functions.between(data, '<span class="cs-network">', '</span>')
		users   = functions.between(data, '<span class="cs-users">', ' &ndash; </span>')
		topic   = functions.between(data, '<span class="cs-topic">', '</span><br>')
		if not topic:
			topic = 'No channel topic set.'
		channels[channel] = {'network':network,'users':users,'topic':topic}
	return channels
Esempio n. 8
0
def ask(query):
    params = httplib.data_encode({
        'input': query,
        'appid': config.api.wolfram_api_key
    })
    data = httplib.get_source('http://api.wolframalpha.com/v2/query?' + params)
    results = {}
    tree = etree.fromstring(data)
    for e in tree.findall('pod'):
        for item in [ef for ef in list(e) if ef.tag == 'subpod']:
            for it in [i for i in list(item) if i.tag == 'plaintext']:
                if it.tag == 'plaintext':
                    results[e.get('title')] = it.text
    if 'Result' in results:
        return results['Result']
    else:
        return False