GithubHelp home page GithubHelp logo

instantnews's Introduction

instantnews

Get news instantly! 🎶 📰

Released v1.2.3

PyPI Gitter

Install

An API key from newsapi will be required and you can register for one here.

Using pip

$ pip install instantnews

Using pip upgrade

$ pip install instantnews --upgrade

Set your API key in an environment variable IN_API_KEY

For example:

export IN_API_KEY="<YOUR_API_TOKEN>"

Build from source

$ git clone https://github.com/shivam043/instantnews.git
$ cd instantnew
$ python setup.py install

Note:

Python 2.7 and Python 3 compatible

Usage

Get help

$ instantnews -h/--help  #Get Help
usage: instantnews [-h] [--show SHOW] [--show_all] [--news NEWS]

optional arguments:
  -h, --help            show this help message and exit
  --show SHOW, -s SHOW  Shows all the news channel codes category wise
  --show_all, -sa       Shows all the news channel codes
  --news NEWS, -n NEWS  Shows news

Get news-code category-wise/all

$ instantnews -sa/--show_all
forexample:
instantnews --show_all
News Code: <abc-news-au> ABC News (AU)
News Code: <al-jazeera-english> Al Jazeera English
News Code: <ars-technica> Ars Technica
News Code: <associated-press> Associated Press
News Code: <bbc-news> BBC News
News Code: <bbc-sport> BBC Sport
News Code: <bild> Bild
News Code: <bloomberg> Bloomberg
News Code: <breitbart-news> Breitbart News .....

$ instantnews -s/--show business
forexample:
instantnews --show business  # Categories available-'business','entertainment','gaming','general','music','politics','science-and-nature','sport','technology'
News Code: <bloomberg> Bloomberg
News Code: <business-insider> Business Insider
News Code: <business-insider-uk> Business Insider (UK)
News Code: <cnbc> CNBC
News Code: <die-zeit> Die Zeit
News Code: <financial-times> Financial Times
News Code: <fortune> Fortune
News Code: <handelsblatt> Handelsblatt

Get news

$ instantnews -n/--news  [news-id]
forexample:
instantnews --news bbc-news
[0] Title: Trump denies NFL kneel row race-related
Author: BBC News
Summary: Donald Trump says his words about political protests at sport events had "nothing to do with race".
--------------------------------------------
[1] Title: Germany's AfD to fight 'foreign invasion'
Author: BBC News
Summary: Nationalists lay out their plans after winning nearly 13% of the vote, weakening Chancellor Merkel.
--------------------------------------------
........
Want to see the news that interests you/open in a webpage? Enter Y/N # See news in a webpage by enter the number present in the box

License

Open sourced under MIT License

instantnews's People

Contributors

c-w avatar ghost-hacked avatar limitedatonement avatar shivam043 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

instantnews's Issues

KeyError: 'articles'

Hi! I install this package and be able to get codes/categories description, but when I try to run exact news-id, I get following error:

Traceback (most recent call last):
  File "c:\anaconda\envs\py353\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\anaconda\envs\py353\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Anaconda\envs\py353\Scripts\instantnews.exe\__main__.py", line 9, in <module>
  File "c:\anaconda\envs\py353\lib\site-packages\instantnews.py", line 162, in parser
    show_news(args.news,BASE_URL)   
  File "c:\anaconda\envs\py353\lib\site-packages\instantnews.py", line 95, in show_news
    for i in t['articles']:
KeyError: 'articles'

I get API key, running on Windows7/Python3.5.3/cmd

Write unit tests

Unit tests should be written for this code. The user shouldn't have to manually test if everything still works after making a change in the code.

Cant get past "open article in webbrowser"

Would you like to open an article in a web browser? Enter (y/n):
y
Traceback (most recent call last):
File "/home/nickb/.local/bin/instantnews", line 11, in
sys.exit(parser())
File "/home/nickb/.local/lib/python2.7/site-packages/instantnews.py", line 171, in parser
show_news(args.news, BASE_URL)
File "/home/nickb/.local/lib/python2.7/site-packages/instantnews.py", line 122, in show_news
choice = (input()).lower()
File "", line 1, in
NameError: name 'y' is not defined

Same happens if I enter a number.

Need to add .gitignore

A .gitignore file should be added to ignore the build/ directory that is created when building locally.

Unicode issues

There seem to be some unicode issues on certain characters within the feeds. I'm seeing this error on almost every news site:

» in -n techcrunch
Traceback (most recent call last):
  File "/usr/local/bin/instantnews", line 11, in <module>
    sys.exit(parser())
  File "/Library/Python/2.7/site-packages/instantnews.py", line 171, in parser
    show_news(args.news, BASE_URL)
  File "/Library/Python/2.7/site-packages/instantnews.py", line 114, in show_news
    print('[{0}] {1}: {2}'.format(len(article_list), "Title", article['title']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 43: ordinal not in range(128)
» in -n cnbc
[0] Title: Trump says Michael Flynn's actions during transition were 'lawful' and 'there was nothing to hide'
Author: Javier E. David
Summary: President Donald Trump said he fired former national security advisor Michael Flynn for lying, but his actions were "lawful."
--------------------------------------------
[1] Title: Strategist Jim Paulsen says prepare for a stock market correction in 2018
Author: Trent Gillies
Summary: Jim Paulsen, Leuthold Group's chief investment strategist, says its time for investors to rebalance their 401(k)s since a market correction is coming soon.
--------------------------------------------
[2] Title: Even a $1 million retirement nest egg isn't enough anymore
Author: Jessica Dickler
Traceback (most recent call last):
  File "/usr/local/bin/instantnews", line 11, in <module>
    sys.exit(parser())
  File "/Library/Python/2.7/site-packages/instantnews.py", line 171, in parser
    show_news(args.news, BASE_URL)
  File "/Library/Python/2.7/site-packages/instantnews.py", line 116, in show_news
    print('{0}: {1}'.format("Summary", article['description']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 102: ordinal not in range(128)

» in -n bloomberg
[0] Title: Trump Says He's `Unbeatable' in 2020 on Tax Cuts, Stock Market
Author: Jennifer Jacobs
Traceback (most recent call last):
  File "/usr/local/bin/instantnews", line 11, in <module>
    sys.exit(parser())
  File "/Library/Python/2.7/site-packages/instantnews.py", line 171, in parser
    show_news(args.news, BASE_URL)
  File "/Library/Python/2.7/site-packages/instantnews.py", line 116, in show_news
    print('{0}: {1}'.format("Summary", article['description']))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 197: ordinal not in range(128)

installed via pip

README needs to be updated

In the README, the user is instructed to create an environment variable for the API key called "IN_API_TOKEN". The code checks for an environment variable called "IN_API_KEY". The README should be updated to display the correct environment variable name.

Usage examples could also be reformatted for readability.

jq error

Just installed this in Arch Linux and am getting the issue shown in the capture
jq error

Reformatting of code

The code could be reformatted for readability. Updates could include uniform line spacing and improved Pydoc comments for the functions.

The messages displayed to the user throughout the program could also be updated to be a little more clear and intuitive.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.