def links_to_array(p):
    """Extract links from page"""
    res = []
    all = p.xpath('//a')
    for tag in all:
        if 'href' not in tag.attrib:
            continue
        else:
            item = {'href' : tag.attrib['href'], 'text' : tag.text_content()}
            res.append(item)
    return {'total' : len(res), 'list' : res}