Skip to content

Commit 65422f1

Browse files
refactored code
1 parent f535f6c commit 65422f1

File tree

9 files changed

+290
-593
lines changed

9 files changed

+290
-593
lines changed

.gitignore

100644100755
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/dist/
33
/*.egg
44
/*.egg-info
5+
.idea/
6+
build/

LICENSE.txt renamed to LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Nikhil Kumar Singh
3+
Copyright (c) 2019 Nikhil Kumar Singh
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include README.rst
1+
include README.md LICENSE

README.md

100644100755
Lines changed: 73 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,92 @@
1-
[![PyPI](https://img.shields.io/badge/PyPi-v1.0.2-f39f37.svg)](https://pypi.python.org/pypi/gnewsclient)
1+
[![PyPI](https://img.shields.io/badge/PyPi-v1.1-f39f37.svg)](https://pypi.python.org/pypi/gnewsclient)
22
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/nikhilkumarsingh/gnewsclient/blob/master/LICENSE.txt)
33

44
# gnewsclient
55

66
An easy-to-use python client for [Google News feeds](https://news.google.com/).
77

8-
gnewsclient supports Python 2 as well as Python 3.
9-
108
## Installation
119

1210
To install gnewsclient, simply,
1311
```
1412
$ pip install gnewsclient
1513
```
1614

17-
## Filters
18-
19-
Google News feeds use 3 basic filters:
20-
21-
- **Edition**<br/>
22-
Limits results to a specific edition.<br/>
23-
There are more than 70 regional editions of Google News in many different languages. Each edition is specifically
24-
tailored with news for that audience.
25-
26-
27-
- **Topic**<br/>
28-
Limits results to a specific topic.<br/>
29-
There are several custom topics like sports, business, world, health, science, politics, etc.
30-
31-
32-
- **Location**<br/>
33-
Limits results to a specific location.
34-
35-
Other than these, you can also specify:
36-
37-
- **Language**<br/>
38-
Provides results in specified language.<br/>
39-
60+ languages are supported.
40-
41-
42-
- **Query**<br/>
43-
Provide results according to a specific query.
44-
4515
## Usage
4616

47-
- Create a gnewsclient object:
48-
```python
49-
>>> from gnewsclient import gnewsclient
50-
>>> client = gnewsclient()
51-
```
17+
- Create a NewsClient object:
18+
```python
19+
>>> from gnewsclient import gnewsclient
20+
>>> client = gnewsclient.NewsClient(language='hindi', location='india', topic='Business')
21+
```
5222

5323
- Get current parameter settings
54-
```python
55-
>>> client.get_config()
56-
{'edition': 'United States (English)',
57-
'language': 'english',
58-
'loaction': None,
59-
'query': None,
60-
'topic': 'top stories'}
61-
```
24+
```python
25+
>>> client.get_config()
26+
{'location': 'india', 'language': 'hindi', 'topic': 'Sorts'}
27+
```
6228

6329
- Get news feed
64-
```python
65-
>>> client.get_news()
66-
[{'img': 'https://t1.gstatic.com/images?q=tbn:ANd9GcQ5KFdYdQclmxUdvdV2zYQ_hO7JMrG2864ZDdN9A3GxORmTf_issciogLEEZmA5QIFfRQsyYDlm',
67-
'link': 'https://www.washingtonpost.com/world/french-citizens-vote-in-an-uncertain-race-that-could-determine-europes-future/2017/04/23/fd3759ce-1fa4-11e7-bb59-a74ccaf1d02f_story.html',
68-
'title': "French citizens vote in an uncertain race that could determine Europe's future - Washington Post"},
69-
{'img': 'https://t0.gstatic.com/images?q=tbn:ANd9GcTfosRmEfpoH40YiX5dyEIgL5rw-OSgcsKGEYhIm15f-OVQmWoidnH5NZD6P1vwaZfpQ33Xt8tZ',
70-
'link': 'https://www.washingtonpost.com/national/health-science/big-turnout-expected-for-march-for-science-in-dc/2017/04/21/67cf7f90-237f-11e7-bb9d-8cd6118e1409_story.html',
71-
'title': "Why people are marching for science: 'There is no Planet B' - Washington Post"},
72-
{'img': 'https://t2.gstatic.com/images?q=tbn:ANd9GcRw4xGtSrL5ZCpDkp5QHLUBPLgDNCsFFpgjJeOdD2q4w4giPDsDf9G3NOAZeNYWOf8f5V1aYTLu',
73-
'link': 'https://www.washingtonpost.com/politics/nearing-100-days-trumps-approval-at-record-lows-but-his-base-is-holding/2017/04/22/a513a466-26b4-11e7-b503-9d616bd5a305_story.html',
74-
'title': "Nearing 100 days, Trump's approval at record lows but his base is holding - Washington Post"}
75-
]
76-
```
77-
78-
- Changing paramteres
79-
```python
80-
>>> client.edition = 'India (Hindi)'
81-
>>> client.topic = 'sports'
82-
>>> client.language = 'hindi'
83-
>>> client.get_news()
84-
[{'img': 'https://t0.gstatic.com/images?q=tbn:ANd9GcTSo3cJx_-NKmtcsAaB8ZNC6tVF-FzU7FxLMmT9GwETYw-h_XmgzE_Ux2Bz3e2dk_iRUsaCIwbY',
85-
'link': 'http://aajtak.intoday.in/sports/story/ms-dhoni-is-the-captain-of-shane-warnes-all-time-ipl-eleven-1-925107.html',
86-
'title': 'वॉर्न की IPL टीम में भारतीयों का बोलबाला, धोनी को सौंपी कप्तानी - आज तक'},
87-
{'img': 'https://t1.gstatic.com/images?q=tbn:ANd9GcTlK3tT02bbryKfJS_l-fbICNHDUFsaXktMQSnvg_Pi-TWMBknuvBL3OhViOGzhjOcMtig4pg3t',
88-
'link': 'http://www.patrika.com/news/kanpur/jwala-gutta-says-up-government-should-make-strategy-for-better-sports-hindi-news-1560241/',
89-
'title': 'प्यार का करारनामा, इंटरनेशनल बैडमिंटन प्लेयर ज्वाला गुट्टा के हाथ पर नजर आया! - Patrika'}
90-
]
91-
```
92-
93-
- Get news by query
94-
```python
95-
>>> client.query = 'cricket'
96-
>>> client.get_news()
97-
[{'img': 'https://t2.gstatic.com/images?q=tbn:ANd9GcTQ6zOoooNhFaXM7bdl2WmmuJkHdE5ED26Mp2QtaRyKELMlBuvc62LmDVgt7-D3m7mgIPGI4vXf',
98-
'link': 'http://www.espncricinfo.com/west-indies-v-pakistan-2017/content/story/1094080.html',
99-
'title': 'West Indies v Pakistan, 1st Test, Kingston, 2nd day April 22, 2017 - ESPNcricinfo.com'},
100-
{'img': 'https://t1.gstatic.com/images?q=tbn:ANd9GcRePCUSgV_AXDrzSe59DsO7j6tgdcfWWocnusHc4OtLxNtGNloVuh_HPA1BtibucOTO9r-qwtNL',
101-
'link': 'https://thefield.scroll.in/835391/cricket-china-bowled-out-for-28-in-world-league-qualifier',
102-
'title': 'Cricket: China bowled out for 28 in World League qualifier - Scroll.in'},
103-
{'img': 'https://t2.gstatic.com/images?q=tbn:ANd9GcSpVMJHsdo6Q5SxuIzwrBHn7seXis3zwryH5ohRyeLVZj3phQDX1e92HZqW7iODBeJM7mrGf7yH',
104-
'link': 'http://www.hindustantimes.com/ipl-2017/live-cricket-score-ipl-2017-t20-mumbai-indians-vs-delhi-daredevils-live/story-CLQVOWa9v8ub7clUSz41LN.html',
105-
'title': 'Full Cricket Score, IPL 2017, T20, Mumbai Indians vs Delhi Daredevils: MI beat DD by 14 runs - Hindustan Times'}
106-
]
107-
```
108-
109-
- Get news by location
110-
```python
111-
>>> client.loaction = 'delhi'
112-
>>> client.get_news()
113-
[{'img': 'https://t3.gstatic.com/images?q=tbn:ANd9GcQI4mXbCB-bLvuiCqN1BoAyClMWgllzHy8DG9SCNDr3_dH9JpNpgfqTz8UneHeE85jdi0wknyhF',
114-
'link': 'http://timesofindia.indiatimes.com/city/delhi/cops-wrap-city-in-a-multi-layer-security-blanket/articleshow/58305944.cms',
115-
'title': 'MCD polls: Cops wrap Delhi in multi-layer security blanket - Times of India'},
116-
{'img': 'https://t0.gstatic.com/images?q=tbn:ANd9GcTd-gOZQ59kAj-GJ9uEHQ3wbGMF6Y4dI9pkc2B9RI0YyOrBPB4jIljR5zFFRXlB0KjqcuZxkAVl',
117-
'link': 'http://www.financialexpress.com/india-news/mcd-polls-2017-heritage-not-on-any-partys-agenda/637968/',
118-
'title': "MCD polls 2017: Heritage not on any party's agenda - Financial Express"},
119-
{'img': 'https://t1.gstatic.com/images?q=tbn:ANd9GcRK_YvCPtCF1uiA8aKz3LJLPHFP7zAlPHFkotuxL7Jr8DZBnA-w5HfMCe1Q69J7Cpf_AKKsNKeV',
120-
'link': 'http://timesofindia.indiatimes.com/city/delhi/car-owner-booked-for-kashmere-gate-accident/articleshow/58308236.cms',
121-
'title': 'Car owner booked for Kashmere Gate accident - Times of India - Times of India'}
122-
]
123-
```
124-
- Get list of available editions, languages and topics
125-
```python
126-
>>> client.editions
127-
['Germany', 'Poland', 'Morocco', 'Colombia', 'India (Telugu)', 'Australia', 'Hungary', 'India (Malayalam)',
128-
'United Arab Emirates', 'Lebanon', 'Serbia', 'Canada (English)', 'China', 'United States (English)',
129-
'Nigeria', 'Austria', 'Kenya', 'Peru', 'Italy', 'Ghana', 'Ukraine (Russian)', 'Belgium (French)', 'Vietnam',
130-
'South Africa', 'Ethiopia', 'Lithuania', 'Philippines', 'Brazil', 'Saudi Arabia', 'India (Hindi)', 'India (Tamil)',
131-
'United States (Spanish)', 'Latvia', 'Singapore', 'Norway', 'Sweden', 'Canada (French)', 'Egypt', 'Japan',
132-
'Arab world', 'Ukraine (Ukranian)', 'Netherlands', 'Hong Kong', 'Romania', 'United Kingdom', 'Slovakia',
133-
'Czech Republic', 'Chile', 'Indonesia', 'France', 'Bangladesh', 'Taiwan', 'Tanzania', 'Argentina', 'Greece',
134-
'Mexico', 'Pakistan', 'Bulgaria', 'Senegal', 'Zimbabwe', 'Belgium (Dutch)', 'Uganda', 'Turkey', 'Portugal',
135-
'Slovenia', 'Namibia', 'Cuba', 'New Zealand', 'Russia', 'India (English)', 'Botswana', 'Venezuela', 'Israel (Hebrew)',
136-
'Thailand', 'Switzerland', 'Israel (English)', 'Ireland', 'Malaysia']
137-
>>> client.topics
138-
['business', 'politics', 'top stories', 'technology', 'world', 'sports', 'entertainment', 'national']
139-
>>> client.languages
140-
['tamil', 'kannada', 'norwegian', 'swedish', 'bulgarian', 'arabic', 'hindi', 'catalan', 'georgian', 'latvian',
141-
'albanian', 'japanese', 'english', 'german', 'lithuanian', 'chinese simplified', 'polish', 'czech', 'macedonian',
142-
'yiddish', 'turkish', 'dutch', 'urdu', 'serbian', 'basque', 'thai', 'hungarian', 'danish', 'galician', 'latin',
143-
'chinese traditional', 'vietnamese', 'portuguese', 'welsh', 'croatian', 'bengali', 'finnish', 'icelandic',
144-
'azerbaijani', 'swahili', 'malay', 'korean', 'slovak', 'russian', 'irish', 'spanish', 'belarusian', 'french',
145-
'estonian', 'indonesian', 'slovenian', 'italian', 'maltese', 'haitian creole', 'esperanto', 'ukrainian',
146-
'afrikaans', 'filipino', 'gujarati', 'hebrew', 'telugu', 'greek', 'persian', 'romanian']
147-
```
30+
```python
31+
>>> client.get_news()
32+
[{'title': 'शेयर बाजार/ सेंसेक्स 490 अंक की बढ़त के साथ 39055 पर, निफ्टी 150 प्वाइंट ऊपर 11726 पर बंद - दैनिक भास्कर',
33+
'link': 'https://www.bhaskar.com/national/news/stock-market-sensex-jumps-500-points-nifty-up-150-points-on-wednesday-24-april-01529551.html',
34+
'media': None},
35+
{'title': 'Reliance Jio की सेवाएं हो सकती हैं महंगी! यह है वजह - Jansatta',
36+
'link': 'https://www.jansatta.com/business/reliance-jio-planning-to-hike-in-prices-to-invest-9000-crore-in-capacity-lease-deals/990616/',
37+
'media': None},
38+
{'title': 'डील/ एस्सेल प्रोपैक की कंट्रोलिंग हिस्सेदारी 3211 करोड़ रुपए में खरीदेगी ब्लैकस्टोन - दैनिक भास्कर',
39+
'link': 'https://www.bhaskar.com/national/news/blackstone-snaps-up-essel-propack-for-rs-3211-cr-01528505.html',
40+
'media': 'https://lh3.googleusercontent.com/proxy/XgI0fJc8QD0syNzTzYgSyerob_9QSyKEIKZAdGecQ-C4u5HxjqcW-HrpuglbWj8CoxLDcrxOzT7QS7GNJxGv6kt6cviIzKpsaGpsr4qEwpyc=-w150-h150-c'},
41+
{'title': 'मारुति सुजुकी की बलेनो हुई स्मार्ट, जानें कीमत और खास फीचर्स - Hindustan',
42+
'link': 'https://www.livehindustan.com/business/story-maruti-suzuki-launched-new-smart-baleno-know-price-and-features-2500723.html',
43+
'media': 'https://lh6.googleusercontent.com/proxy/Jwm-p9YBF5bT3bcsXv5KGn_83nniRJsi9CArg1yU27LrKMu72cl1ekX4na_e9JfjhWHrRKD-LWLdUiK1H91VnB_gwVhoJNQX_AvhLaKUId-uodvOMDIe=-w150-h150-c'}]
44+
```
45+
46+
- Changing parameters
47+
```python
48+
>>> client.location = 'india'
49+
>>> client.language = 'hindi'
50+
>>> client.topic = 'Sports'
51+
>>> client.get_news()
52+
[{'title': 'जब डिविलियर्स ने एक हाथ से मारा शॉट, ग्राउंड के पार पहुंची गेंद - आज तक',
53+
'link': 'https://aajtak.intoday.in/sports/story/rcb-vs-kxip-ab-de-villiers-one-handed-six-out-of-the-ground-tspo-1-1078680.html',
54+
'media': None},
55+
{'title': 'हितों का टकराव: बीसीसीआई लोकपाल ने सचिन तेंडुलकर और वीवीएस लक्ष्मण को नोटिस जारी किया - Navbharat Times',
56+
'link': 'https://navbharattimes.indiatimes.com/sports/cricket/iplt20/news/ombudsman-notice-to-sachin-tendulkar-vvs-laxman-cricketers-doing-voluntary-service/articleshow/69031167.cms',
57+
'media': None},
58+
{'title': 'आंद्रे रसेल और गेल को मिला आईपीएल का ईनाम, वेस्टइंडीज की विश्वकप 2019 टीम में मिली जगह - India TV हिंदी',
59+
'link': 'https://hindi.indiatvnews.com/sports/cricket-world-cup-2019-westindies-team-squad-2019-chris-gayle-and-andre-russell-got-place-633917',
60+
'media': None},
61+
{'title': 'Macth Update, IPL 2019, RCB vs KXIP: पंजाब को हराकर बैंगलोर ने लगाई जीत की हैट्रिक, प्लेऑफ की दौड़ में बरकरार - Times Now Hindi',
62+
'link': 'https://hindi.timesnownews.com/cricket/article/ipl-live-score-rcb-vs-kxip-royal-challengers-bangalore-vs-kings-xi-punjab-m-chinnaswamy-stadium-ipl-2019-live-match-score-in-hindi/406206',
63+
'media': None}
64+
]
65+
```
66+
67+
- Get list of available locations, languages and topics
68+
```python
69+
>>> client.locations
70+
['Australia', 'Botswana', 'Canada ', 'Ethiopia', 'Ghana', 'India ', 'Indonesia', 'Ireland', 'Israel ', 'Kenya', 'Latvia',
71+
'Malaysia', 'Namibia', 'New Zealand', 'Nigeria', 'Pakistan', 'Philippines', 'Singapore', 'South Africa', 'Tanzania', 'Uganda',
72+
'United Kingdom', 'United States', 'Zimbabwe', 'Czech Republic', 'Germany', 'Austria', 'Switzerland', 'Argentina', 'Chile',
73+
'Colombia', 'Cuba', 'Mexico', 'Peru', 'Venezuela', 'Belgium ', 'France', 'Morocco', 'Senegal', 'Italy', 'Lithuania',
74+
'Hungary', 'Netherlands', 'Norway', 'Poland', 'Brazil', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Sweden', 'Vietnam',
75+
'Turkey', 'Greece', 'Bulgaria', 'Russia', 'Ukraine ', 'Serbia', 'United Arab Emirates', 'Saudi Arabia', 'Lebanon', 'Egypt',
76+
'Bangladesh', 'Thailand', 'China', 'Taiwan', 'Hong Kong', 'Japan', 'Republic of Korea']
77+
>>> client.languages
78+
['english', 'indonesian', 'czech', 'german', 'spanish', 'french', 'italian', 'latvian', 'lithuanian', 'hungarian', 'dutch',
79+
'norwegian', 'polish', 'portuguese brasil', 'portuguese portugal', 'romanian', 'slovak', 'slovenian', 'swedish', 'vietnamese',
80+
'turkish', 'greek', 'bulgarian', 'russian', 'serbian', 'ukrainian', 'hebrew', 'arabic', 'marathi', 'hindi', 'bengali', 'tamil',
81+
'telugu', 'malyalam', 'thai', 'chinese simplified', 'chinese traditional', 'japanese', 'korean']
82+
>>> client.topics
83+
['Top Stories',
84+
'World',
85+
'Nation',
86+
'Business',
87+
'Technology',
88+
'Entertainment',
89+
'Sports',
90+
'Science',
91+
'Health']
92+
```

0 commit comments

Comments
 (0)