World-News-Analysis / wna_googlenews.py
Roozeec's picture
updated news parsing
60f5e0a
raw
history blame contribute delete
630 Bytes
# https://github.com/Iceloof/GoogleNews
from GoogleNews import GoogleNews
import pandas as pd
# get the news with lang and country parameters
def get_news(settings, query):
googlenews = GoogleNews(
lang=settings["lang"],
region=settings["region"],
period=settings["period"],
)
number_of_pages = settings["number_of_pages"]
# get each pages
final_list = []
googlenews.search(query)
print("Total Pages: ", googlenews.total_count())
for page in range(1, number_of_pages + 1):
page_result = googlenews.page_at(page)
# merge dat
final_list = final_list + page_result
return final_list