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

def _extract_bookmarks_from_url_history(self, data):

    bookmarks = []
    soup = BeautifulSoup(data)
    bookmark_elements = soup.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')
        comment = u''
        datas = bookmark_element.findAll('div', attrs={'class': 'data'})
        if datas:
            divs = datas[0].findAll('div', attrs={'class': 'description'})
            if divs:
                comment = divs[0].contents[0].strip()
        user_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]
                user_tags.append(tag)
        metas = bookmark_element.findAll('div', attrs={'class': 'meta'})
        if metas:
            links = metas[0].findAll('a', attrs={'class': 'user    user-tag'})
            if links:
                try:
                    user = links[0]['href'][1:]
                except IndexError:
                    pass
                bookmarks.append((user, user_tags, comment, timestamp))
    return bookmarks
