'Extracts a user\'s bookmarks from his user page on Delicious.com.
The Python library BeautifulSoup is used to parse the HTML page.
@param data: The HTML source of a user page on Delicious.com.
@type data: str
@return: list of bookmarks of the corresponding user'

def _extract_bookmarks_from_user_history(self, data):

    bookmarks = []
    soup = BeautifulSoup(data)
    ul = soup.find('ul', id='bookmarklist')
    if ul:
        bookmark_elements = ul.findAll('div', attrs={'class': re.compile('^bookmark\\s*')})
        timestamp = None
        for bookmark_element in bookmark_elements:
            dategroups = bookmark_element.findAll('div', attrs={'class': 'dateGroup'})
            if dategroups:
                spans = dategroups[0].findAll('span')
                if spans:
                    date_str = spans[0].contents[0].strip()
                    timestamp = datetime.datetime.strptime(date_str, '%d    %b    %y')
            url = u''
            title = u''
            comment = u''
            datas = bookmark_element.findAll('div', attrs={'class': 'data'})
            if datas:
                links = datas[0].findAll('a', attrs={'class': re.compile('^taggedlink\\s*')})
                if (links and links[0].contents):
                    title = links[0].contents[0].strip()
                    url = links[0]['href']
                divs = datas[0].findAll('div', attrs={'class': 'description'})
                if divs:
                    comment = divs[0].contents[0].strip()
            url_tags = []
            tagdisplays = bookmark_element.findAll('div', attrs={'class': 'tagdisplay'})
            if tagdisplays:
                aset = tagdisplays[0].findAll('a', attrs={'class': 'tag    noplay'})
                for a in aset:
                    tag = a.contents[0]
                    url_tags.append(tag)
            bookmarks.append((url, url_tags, title, comment, timestamp))
    return bookmarks
