How can I get news in real-time in Python?

I am currently working on a project that requires me to collect news articles in Python under certain filters in real-time. I am doing this using the get_news_headlines() function and it works well. The only issue is that once I tried to run the code over an interval of 10 minutes, it did not collect any news. After further testing, I realized that news published within the previous 2 hours from the current time cannot be collected. For example, when I run the program at 8am, I can only collect data on news that were published at 6am or before.

Could someone help me with this issue please?

Best Answer

  • @azzopardic

    I do not reproduce the issue you describe on my end. Are you sure you're not misinterpreting news headlines timestamps returned by get_news_headlines method? The timestamps are returned in GMT, not in your local time zone.

Answers

  • I did not know they were returned in GMT, and given I am in CET, it does make sense. Thank you so much.