How to store as data frame with for loop request.
import time
from tqdm.notebook import tqdm
from GoogleNews import GoogleNews
from newspaper import Article
countries = df["Country"].unique().tolist()
print(countries)
#Output:
-----------
['Malaysia', 'ireland', 'CZ', 'India', 'USA']
Now like if want to get google news data and store all data by country in a Dataframe.
list_country = []
df = pd.DataFrame([])
for country in tqdm(countries1):
googlenews = GoogleNews(start=Start_date,end=End_date)
googlenews.set_lang('en')
googlenews.set_encode('utf-8')
googlenews.get_news(country)
googlenews.total_count()
result=googlenews.result()
data=pd.DataFrame(result)
df = df.append(data)
df['Country'] = country
list_country.append(country)
df.head()
Expected output like:
But in result only store last country's result.