HackerNewsAPI icon indicating copy to clipboard operation
HackerNewsAPI copied to clipboard

Cannot parse result

Open phuthinh2202 opened this issue 8 years ago • 1 comments

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

phuthinh2202 avatar Jun 23 '17 03:06 phuthinh2202

+1, I am seeing the exact same issue. This module hasn't been updated in years, maybe there is a fork that is actively being maintained, but there are too many to try to search through them.

Also, there is a REST API for HN, so I don't know why this module is scraping HTML.

sjf avatar Jan 26 '20 16:01 sjf