Skip to content

Commit 106dcb8

Browse files
authored
Merge pull request #11 from banta-isaiah/master
Authentication, Type/Value checks, Use of News API error messages, and addressed a Windows cmd error
2 parents 8a9ccfa + 38074cf commit 106dcb8

4 files changed

Lines changed: 273 additions & 49 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dist/
66
*.rst
77
venv/
88
*log.txt
9+
*~

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,25 @@ api.get_everything(q='bitcoin')
5656
api.get_sources()
5757
```
5858

59+
## For Windows users printing to _cmd_ or _powershell_
60+
61+
You will encounter an error if you attempt to print the .json() object to the command line. This is because the '{', '}' curly braces to be printed to the console.
62+
This becomes especially annoying if developers wish to get 'under the hood'.
63+
64+
Here is the error:
65+
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 1444: character maps to <undefined>
66+
67+
This can be fixed by:
68+
- installing 'win-unicode-console'
69+
`py -mpip install win-unicode-console`
70+
- then running it while calling your python script...
71+
`py -mrun myPythonScript.py`
72+
73+
Another option is hardcoding your console to only print in utf-8. This is a bad idea, as it could ruin many other scripts and/or make errors MUCH more difficult to track.
74+
[More information](https://stackoverflow.com/questions/5419/python-unicode-and-the-windows-console/32176732#32176732
75+
76+
5977
## Support
6078

6179
Feel free to make suggestions or provide feedback regarding the library. Thanks.
62-
Reach out at [lisivickmatt@gmail.com]('mailto:lisivickmatt@gmail.com')
80+
Reach out at [lisivickmatt@gmail.com]('mailto:lisivickmatt@gmail.com')

newsapi/const.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
TOP_HEADLINES_URL = 'https://newsapi.org/v2/top-headlines'
2+
EVERYTHING_URL = 'https://newsapi.org/v2/everything'
3+
SOURCES_URL = 'https://newsapi.org/v2/sources'
4+
5+
countries = {'ae','ar','at','au','be','bg','br','ca','ch','cn','co','cu','cz','de','eg','fr','gb','gr','hk',
6+
'hu','id','ie','il','in','it','jp','kr','lt','lv','ma','mx','my','ng','nl','no','nz','ph','pl',
7+
'pt','ro','rs','ru','sa','se','sg','si','sk','th','tr','tw','ua','us','ve','za'}
8+
9+
languages = {'ar','en','cn','de','es','fr','he','it','nl','no','pt','ru','sv','ud'}
10+
11+
categories = {'business', 'entertainment', 'general', 'health', 'science', 'sports', 'technology'}
12+
13+
sort_method = {'relevancy','popularity','publishedAt'}

0 commit comments

Comments
 (0)