Exemple #1
0
def current(num=0):
    response = _buildResponse(CURRENT_URL)
    html = response.read()
    pdoc = lxml.html.fromstring(html)
    results = [t for t in pdoc.body.cssselect('table tr td.title a')]
    result = results[num]
    title = result.text_content()
    href= result.attrib['href']
    return "<{C8}%s{} | {LINK}%s{}>  {C13}[%s of %s]{}" % (title, href, num, len(results)-1)
Exemple #2
0
def search(query, num=0):
    #only search current for now 
    response = _buildResponse(CURRENT_URL)
    html = response.read()
    pdoc = lxml.html.fromstring(html)
    results = [t for t in pdoc.body.cssselect('table tr td.title a')]
    
    d = dict([(result.attrib['href'],result.text_content()) for result in results])
    
    search_re = re.compile('%s' % query, re.I)
    
    matches = []
    
    for href,text in d.items():
        if search_re.search(text):
            matches.append("<{C8}%s{} | {LINK}%s{}>" % (text,href))

    if not len(matches): return "No results found. =("
    
    return matches[num] + " {C13}[%s of %s]{}" % (num, len(matches)-1)