Iceloof / GoogleNews

Script for GoogleNews
https://pypi.org/project/GoogleNews/
MIT License
316 stars 88 forks source link

news only in english #26

Closed Alexandros11 closed 4 years ago

Alexandros11 commented 4 years ago

Whenever i try to get data it downloads only data in english. Here is the code:

from GoogleNews import GoogleNews

googlenews = GoogleNews()
googlenews = GoogleNews(lang = 'de')
googlenews = GoogleNews(start ='01/05/2019' ,end ='07/01/2019')
googlenews.search('Frankfurt')
result = googlenews.result()

for n in range(len(result)):
    print(n)
    for index in result[n]:
        print(index, '\n', result[n][index])

print(len(result))

and here is part of output:

0
title 
 Penalty heartbreak for Eintracht Frankfurt as Chelsea book ...
media 
 Deutsche Welle
date 
 9 may 2019
desc 
 The German side came so close to the Europa League final, but finally fell to Chelsea on penalties. Europa League - FC Chelsea v Eintracht Frankfurt | ...
link 
 https://www.dw.com/en/penalty-heartbreak-for-eintracht-frankfurt-as-chelsea-book-english-europa-league-final/a-48678619
img 
 https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTpPc81Q_BdksRefghIs5VOt_w4cnPiye5fKYNd3KMkv-RywSnEgnsqncYLUXTychL9hH5N83s&s
1
title 
 Germany: Russian millionaire killed in Frankfurt plane crash
media 
 Deutsche Welle
date 
 31 mar 2019
desc 
 One of Russia's richest women, Natalia Fileva, has died in a plane crash near Frankfurt, Germany. The cause of the accident was not immediately clear.
link 
 https://www.dw.com/en/germany-russian-millionaire-killed-in-frankfurt-plane-crash/a-48138292
img 
 https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR1H3RncCLG4oX1aNgI9Mljc8Diti3_ILA_Nki-4TAJIF1qa1rWChdlDHQbHFqJKoIU0iRe5qY8&s

I am using Ubuntu 18.04.4 LTS. I tried to change my system locale to LANG=de_DE.UTF-8. Unfortunately, it didnt help... Thank you in advance.

HurinHu commented 4 years ago
googlenews = GoogleNews()
googlenews.setlang('de')
googlenews.setTimeRange('01/05/2019','01/05/2019')
googlenews.search('Frankfurt')
result = googlenews.result()

You create object three times with different parameters, that is why you only get the last googlenews = GoogleNews(start ='01/05/2019' ,end ='07/01/2019')