예제 #1
0
def getwikidata(url):
    """ fetch wiki data """
    result = fromenc(geturl(url))
    if not result:
        return
    res = rsslist(result)
    txt = ""
    for i in res:
        try:
            txt = i['text']
            break
        except:
            pass
    if not txt:
        return
    #txt = re.sub('\[\[Image:([^\[\]]+|\[\[[^\]]+\]\])*\]\]', '', txt)
    txt = txt.replace('[[', '')
    txt = txt.replace(']]', '')
    txt = re.sub('\s+', ' ', txt)
    return txt
예제 #2
0
def getwikidata(url, ievent):
    """ fetch wiki data """
    try:
        result = fromenc(geturl(url))
    except IOError, ex:
        try:
            errno = ex[0]
        except IndexError:
            handle_exception(ievent=ievent)
            return
        ievent.reply('invalid option')
        return
    if not result:
        ievent.reply("can't find data for %s" % url)
        return
    res = rsslist(result)
    txt = ""
    for i in res:
        try:
            txt = i['text']
            break
        except:
            pass
    if not txt:
        ievent.reply("no data found on %s" % url)
        return
    #txt = re.sub('\[\[Image:([^\[\]]+|\[\[[^\]]+\]\])*\]\]', '', txt)
    txt = txt.replace('[[', '')
    txt = txt.replace(']]', '')
    txt = re.sub('\s+', ' ', txt)
    return txt
예제 #3
0
def getwikidata(url, ievent):
    """ fetch wiki data """
    try:
        result = fromenc(geturl(url))
    except IOError, ex:
        try:
            errno = ex[0]
        except IndexError:
            handle_exception(ievent=ievent)
            return
        ievent.reply('invalid option')
        return
    if not result:
        ievent.reply("can't find data for %s" % url)
        return
    res = rsslist(result)
    txt = ""
    for i in res:
        try:
            txt = i['text']
            break
        except:
            pass
    if not txt:
        ievent.reply("no data found on %s" % url)
        return
    #txt = re.sub('\[\[Image:([^\[\]]+|\[\[[^\]]+\]\])*\]\]', '', txt)
    txt = txt.replace('[[', '')
    txt = txt.replace(']]', '')
    txt = re.sub('\s+', ' ', txt)
    return txt