https://github.com/sanogotech/pythondailycode
Python Daily Code
https://github.com/sanogotech/pythondailycode
python
Last synced: 2 months ago
JSON representation
Python Daily Code
- Host: GitHub
- URL: https://github.com/sanogotech/pythondailycode
- Owner: sanogotech
- Created: 2022-09-09T10:32:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-09T11:51:41.000Z (over 2 years ago)
- Last Synced: 2025-02-09T00:16:50.591Z (4 months ago)
- Topics: python
- Language: Python
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: newsapi.py
Awesome Lists containing this project
README
# pythondailycode
Python Daily Code## Docs
- https://python.plainenglish.io/10-python-automation-scripts-for-everyday-problems-3ca0f2011282
- https://python.plainenglish.io/from-zero-to-hero-in-python-in-just-10-minutes-83064ffd5aee## Install
```
pip install newsapi-python
```## Code
````
from newsapi import NewsApiClient# Init
newsapi = NewsApiClient(api_key='175b74679bc341e782cc4292c327c9ec')# /v2/top-headlines
top_headlines = newsapi.get_top_headlines(q='bitcoin',
sources='bbc-news,the-verge',
category='business',
language='en',
country='us')# /v2/everything
all_articles = newsapi.get_everything(q='bitcoin',
sources='bbc-news,the-verge',
domains='bbc.co.uk,techcrunch.com',
from_param='2017-12-01',
to='2017-12-12',
language='en',
sort_by='relevancy',
page=2)# /v2/top-headlines/sources
sources = newsapi.get_sources()
```