avinassh / haxor Goto Github PK
View Code? Open in Web Editor NEWUnofficial Python wrapper for official Hacker News API
License: MIT License
Unofficial Python wrapper for official Hacker News API
License: MIT License
Is it possible to make haxor support requests>=2.4.0 to solve this dependency conflict I have?
haxor 1.1 has requirement requests==2.0.0, but you'll have requests 2.18.4 which is incompatible.
When installing haxor
I get this error:
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "/tmp/pip-install-zl_kpo7s/haxor/setup.py", line 6, in <module>
import pypandoc
ImportError: No module named 'pypandoc'
The error won’t occur if I install pypandoc
before haxor
.
The project’s requirements-dev.txt
contains pypandoc
but requirements.txt
does not. Is this intended?
Hi avinassh,
I'm running into performance issues running the examples. It seems the HN API route can be considerably slower than just screen scraping.
Is there a way for me to speed this up? I wonder if the connection to Firebase is being reused--seems like with requests
this should be done automatically?
Using timeit
here are my results:
for story_id in hn.top_stories(limit=10):
print hn.get_item(story_id)
timei
t: 4.0882999897 sec
who_is_hiring = hn.get_item(8394339)
for comment_id in who_is_hiring.kids:
comment = hn.get_item(comment_id)
if 'python' in comment.text.lower():
print comment.item_id
timeit
: 125.318946123 sec
Thanks!
Consider updating Requests dependency due to security issue which impacts versions <= 2.19.1. More on https://nvd.nist.gov/vuln/detail/CVE-2018-18074.
Running tests:
pip install -r requirements-dev.txt
python setup.py develop
pytest tests
produces the following error
RecursionError: maximum recursion depth exceeded while calling a Python object
Python version: 3.6.5
my code:
from hackernews import HackerNews
hn = HackerNews()
output:
:!python /Users/A78751003/projects/py/hn/main.py
Traceback (most recent call last):
File "/Users/A78751003/projects/py/hn/main.py", line 1, in <module>
from hackernews import HackerNews
File "/Users/A78751003/projects/py/hn/.venv/lib/python3.11/site-packages/hackernews/__init__.py", line 19, in <module>
import aiohttp
File "/Users/A78751003/projects/py/hn/.venv/lib/python3.11/site-packages/aiohttp/__init__.py", line 6, in <module>
from .client import * # noqa
^^^^^^^^^^^^^^^^^^^^^
File "/Users/A78751003/projects/py/hn/.venv/lib/python3.11/site-packages/aiohttp/client.py", line 16, in <module>
from . import client_exceptions, client_reqrep
File "/Users/A78751003/projects/py/hn/.venv/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 18, in <module>
from . import hdrs, helpers, http, multipart, payload
File "/Users/A78751003/projects/py/hn/.venv/lib/python3.11/site-packages/aiohttp/helpers.py", line 23, in <module>
import async_timeout
File "/Users/A78751003/projects/py/hn/.venv/lib/python3.11/site-packages/async_timeout/__init__.py", line 10, in <module>
class timeout:
File "/Users/A78751003/projects/py/hn/.venv/lib/python3.11/site-packages/async_timeout/__init__.py", line 40, in timeout
@asyncio.coroutine
^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?
According to stackoverflow that is because asyncio dropped the decorator with python 3.11.
it messes with some of my other packages
Hi, I noticed that the version on pip is outdated as it does not support the descendants
field added recently.
You might want to update it. Temporarily I can solve it by using the github url as the dependency.
Whenever I am using usertp = hn.get_user('dhouston', expand=True) it is giving error RuntimeError: This event loop is already running
Hi, I'm getting the following error trying to install on Python 3.4.3, but it works fine on 2.7.10:
$ pip install haxor
Collecting haxor
Using cached haxor-0.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/var/folders/rp/8nf53wk57bgd12w6fr31rrwh0000gn/T/pip-build-yuswawpl/haxor/setup.py", line 12
print long_description
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/rp/8nf53wk57bgd12w6fr31rrwh0000gn/T/pip-build-yuswawpl/haxor
Calling https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty
from within the browser works fine, however if I try to leverage your wrapper
hn = HackerNews()
top_stories = hn.top_stories()
top_stories
I´ll run into ProtocolError: ('Connection aborted.', TimeoutError(10060,...)
for most of the time.
Any hints?
Thanks.
While running tests, following is printed:
=============================== warnings summary ===============================
tests/test_ask_stories.py::TestAskStories::test_ask_stories
/home/runner/work/haxor/haxor/hackernews/__init__.py:139: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
https://github.com/avinassh/haxor/actions/runs/7166888744/job/19511836841
on stackoverflow: https://stackoverflow.com/questions/73361664/asyncio-get-event-loop-deprecationwarning-there-is-no-current-event-loop
hn = HackerNews()
who_is_hiring = hn.get_item(12202865)
for comment_id in who_is_hiring.kids:
print('processing:- '+str(comment_id))
comment = hn.get_item(comment_id) #this line caused the error
if comment.text is not None:
cleantext = BeautifulSoup(comment.text.lower(),'lxml').text.strip()
comments.append(cleantext)
Error is:
Traceback (most recent call last):
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 331, in _make_request
httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 333, in _make_request
httplib_response = conn.getresponse()
File "/anaconda3/anaconda/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/anaconda3/anaconda/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/anaconda3/anaconda/lib/python3.5/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/adapters.py", line 362, in send
timeout=timeout
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 559, in urlopen
_pool=self, _stacktrace=stacktrace)
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 245, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/packages/six.py", line 309, in reraise
raise value.with_traceback(tb)
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 516, in urlopen
body=body, headers=headers)
File "/anaconda3/anaconda/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 333, in _make_request
httplib_response = conn.getresponse()
File "/anaconda3/anaconda/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/anaconda3/anaconda/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/anaconda3/anaconda/lib/python3.5/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.