namespaces = {'xi': 'http://www.w3.org/2001/XInclude', 'test':
    'http://www.w3.org/1999/xhtml'}
links = pq('#maincontent .linkoutlist test|a', response.content, namespaces
    =namespaces)
for link in links:
    pass
Using lxml to parse namepaced HTML?