Iceloof / GoogleNews

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

[Error] Missing/Empty data entries when deploying to railway.app #69

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello author. I want to report this strange bug.

I tested on local with your library and still working normal. the "entries" part is still exists: https://pastebin.com/xYs8pmkv

..........
'entries': [
    {
      'title': 'Angela Merkel tiêm vaccine: Liều một AstraZeneca, liều hai Moderna - BBC Tiếng Việt',
      'title_detail': {
        'type': 'text/plain',
        'language': None,
        'base': '',
        'value': 'Angela Merkel tiêm vaccine: Liều một AstraZeneca, liều hai Moderna - BBC Tiếng Việt'
      },
......

But when im trying to deployed on https://railway.app/, the entries somehow return an empty "entries" The log: https://pastebin.com/Sj5ARuVN

....
 'entries': [
    // empty
  ]

The code im using

gn = GoogleNews(lang = 'vi')
    search = gn.search('Covid-19', when = '1h')
    print(search) 
    entries = search['entries']
    print(entries)
HurinHu commented 3 years ago

The reason is your server(IP) was recognized as robot by Google, which means google is not allowed people to use its services on cloud server through script.

ghost commented 3 years ago

So can you recommend alternative soi, library for news ? 😢

HurinHu commented 3 years ago

So can you recommend alternative soi, library for news ? 😢

Probably no api can do this at the moment. Because Google blocks the IP from cloud server provider, which means anything get from google automatically can not be run on cloud server.