'Return a list of urls or a list of (url, title_text) tuples
if specified.'

def _get_urls(self, doc, titles):

    if (doc is None):
        return []
    a_kwargs = {'tag': 'a'}
    a_tags = self.parser.getElementsByTag(doc, **a_kwargs)
    if titles:
        return [(a.get('href'), a.text) for a in a_tags if a.get('href')]
    return [a.get('href') for a in a_tags if a.get('href')]
