Skip to content

Cannot parse result #52

@phuthinh2202

Description

@phuthinh2202

I write some line to get top or newest stories, when i print and get error like this:

./hackernews_api.py
/usr/lib64/python2.7/site-packages/bs4/init.py:181: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 12 of the file ./hackernews_api.py. To get rid of this warning, change code that looks like this:

BeautifulSoup(YOUR_MARKUP})

to this:

BeautifulSoup(YOUR_MARKUP, "html.parser")

markup_type=markup_type))
Traceback (most recent call last):
File "./hackernews_api.py", line 12, in
for story in top_iter:
File "/usr/lib/python2.7/site-packages/hn/hn.py", line 145, in get_stories
stories = self._build_story(all_rows) # get a list of stories on current page
File "/usr/lib/python2.7/site-packages/hn/hn.py", line 71, in _build_story
domain = info_cells[2].find('span').string[2:-2] # slice " (abc.com) "
TypeError: 'NoneType' object has no attribute 'getitem'

Something i went wrong, pls fix.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions