def search(query): channels = {} source = httplib.get_source('http://irc.netsplit.de/channels/?chat=' + query.replace(' ', '+')) for i in ('​', '<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">', ' – </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
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
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
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'
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
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
def search(query): channels = {} source = httplib.get_source('http://irc.netsplit.de/channels/?chat=' + query.replace(' ','+')) for i in ('​','<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">', ' – </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
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