

@classmethod
def fromid(self, item_id):
    '\n        Initializes an instance of Story for given item_id.\n        It is assumed that the story referenced by item_id is valid\n        and does not raise any HTTP errors.\n        item_id is an int.\n        '
    if (not item_id):
        raise Exception('Need an item_id for a story')
    soup = get_item_soup(item_id)
    story_id = item_id
    rank = (- 1)
    info_table = soup.findChildren('table')[2]
    info_rows = info_table.findChildren('tr')
    title_row = info_rows[0].findChildren('td')[1]
    title = title_row.find('a').text
    try:
        domain = title_row.find('span').string[2:(- 2)]
        is_self = False
        link = title_row.find('a').get('href')
    except AttributeError:
        domain = BASE_URL
        is_self = True
        link = ('%s/item?id=%s' % (BASE_URL, item_id))
    meta_row = info_rows[1].findChildren('td')[1].contents
    points = int(re.match('^(\\d+)\\spoint.*', meta_row[0].text).groups()[0])
    submitter = meta_row[2].text
    submitter_profile = ('%s/%s' % (BASE_URL, meta_row[2].get('href')))
    published_time = ' '.join(meta_row[3].strip().split()[:3])
    comments_link = ('%s/item?id=%s' % (BASE_URL, item_id))
    try:
        num_comments = int(re.match('(\\d+)\\s.*', meta_row[4].text).groups()[0])
    except AttributeError:
        num_comments = 0
    story = Story(rank, story_id, title, link, domain, points, submitter, published_time, submitter_profile, num_comments, comments_link, is_self)
    return story

dataset/ETHPy150Open karan/HackerNewsAPI/hn/hn.py Story.fromid/original