Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
hnconnector is a lightweight Python library designed to simplify accessing the Hacker News API. With hnconnector, you can easily fetch stories, comments, user profiles, and other data from Hacker News with minimal setup. Whether you're building a custom Hacker News reader, analyzing Hacker News stories, or integrating Hacker News data into your projects, hnconnector provides a straightforward Pythonic interface to interact with Hacker News.
hnconnector can be installed using pip. Ensure you have Python 3.6 or higher installed on your system. To install hnconnector, open your terminal and run:
pip install hnconnector
Here's a quick example to get you started by fetching the top stories from Hacker News:
from hn import Client
client = Client()
# Fetch top stories
top_stories = client.get_topstories()
print("Top 10 Hacker News Stories IDs:")
for story_id in top_stories[:10]:
print(story_id)
# Fetch details for a specific story
story_details = client.get_item(top_stories[0])
print(f"Details of the top story: {story_details}")
Create an instance of the Client class to start interacting with the API:
from hn import Client
client = Client()
You can fetch different types of stories (top, new, best, ask HN, show HN, and jobs) as follows:
top_stories = client.get_topstories()
new_stories = client.get_newstories()
best_stories = client.get_beststories()
ask_stories = client.get_askstories()
show_stories = client.get_showhn()
job_stories = client.get_jobstories()()
To retrieve details about a specific item (story, comment, etc.), use its ID:
item_id = 16582136
item_details = client.get_item(item_id)
print(item_details)
username = 'dang'
user_details = client.get_user(username)
print(user_details['karma'])
Contributions to hnconnector are welcome!
hnconnector is released under the MIT License. See the LICENSE file for more details.
For questions or feedback regarding hnconnector, please open an issue on the GitHub repository: https://github.com/mfiro/hnconnector.
FAQs
An unofficial Hacker News API Client Library in Python
We found that hnconnector demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.