from GoogleNews import GoogleNews
from newspaper import Article
from newspaper import Config
import pandas as pd
import nltk
from datetime import date
from datetime import datetime
import schedule
def buscar_noticia():
data_inicio = input('informe a data inicial mm/dd/yyyy: ')
data_final = input('informe a data final mm/dd/yyyy: ')
busca = input('Digite o termo a ser buscado: ')
nome_arquivo = input('Informe o nome do arquivo que deseja Salvar: ')
nltk.download('punkt')
user_agent = '(Ubuntu; Ubuntu 18.04.5 LTS) Chrome/ 87.0.4280.88 '
config = Config()
config.browser_user_agent = user_agent
googlenews = GoogleNews(start=data_inicio, end=data_final)
googlenews.set_lang('pt-br')
googlenews.search(busca)
result = googlenews.result()
print(googlenews.result())
df = pd.DataFrame(result)
# print(df.head())
for i in range(1, 2):
googlenews.getpage(i)
result = googlenews.result()
df = pd.DataFrame(result)
list = []
for ind in df.index:
dict = {}
article = Article(df['link'][ind], config=config)
article.download()
article.parse()
article.nlp()
dict['Dias'] = df['date'][ind]
dict['Data'] = df['datetime'][ind]
dict['Midia'] = df['media'][ind]
dict['Link'] = df['link'][ind]
dict['Titulo da Noticia'] = article.title
dict['Artigo'] = article.text
dict['Sumario'] = article.summary
list.append(dict)
news_df = pd.DataFrame(list)
news_df.to_excel(nome_arquivo + ".xlsx")
gostaria de colocar de automatizar esse código, e colocar ele pra rodar a duas vezes por semana, sou iniciante ainda se alguém puder me ajudar ficarei muito grato.