Naas Documentation
Naas.ai
GitHub
Slack Community
What's new?
Search…
Welcome to Naas
😎
Templates
AWS
Airtable
AlphaVantage
Bazimo
Boursorama
Bubble
CCXT
CSV
Canny
Celestrak
Cityfalcon
D-Tale
Dask
Data.gouv.fr
Draft Kings
EM-DAT
Elasticsearch
Excel
FAO
FEC
FTP
GitHub
Gmail
Google Analytics
Google Drive
Google Search
Google Sheets
HTML
Healthchecks
HubSpot
Hugging Face
IFTTT
IMDB
INPI
IUCN
Insee
Instagram
Integromat
Johns Hopkins
Jupyter
Jupyter Notebooks
LinkedIn
Matplotlib
Metrics Store
Microsoft Teams
Microsoft Word
MongoDB
MySQL
NASA
Naas
Naas Auth
Neo
Newsapi
Get data
Send emails briefs
Run sentiment analysis
Notion
OpenWeatherMap
OwnCloud
PDF
Pandas
Pillow
Pipedrive
Plaid
Plotly
PostgresSQL
PyPI
Python
Qonto
Quandl
Reddit
Redshift
Remoteok
Remotive
SAP-HANA
SendGrid
Slack
Snowflake
Societe.com
Spotify
Streamlit
Stripe
Telegram
Thinkific
TikTok
Trello
Twilio
Twitter
WSR
WorldBank
Worldometer
XML
YahooFinance
YouTube
Youtube
ZIP
Zapier
spaCy
Google Analytics
Google Drive
Google Search
Google Sheets
Hugging Face
Johns Hopkins
Jupyter Notebooks
Metrics Store
Microsoft Teams
Microsoft Word
Naas Auth
Elastic Search
Excel 365
🔄
Low-code features
🏎
Low-code drivers
🌎
Community
Essentials
Advanced
Best Practices
FAQ
⚡
Naas manager
🔐
Security
Powered By
GitBook
Send emails briefs
Tags:
#newsapi #news #emailbrief
Author:
Unknown
Source: https://newsapi.org/
Input
Import libraries
1
from
naas_drivers
import
newsapi
2
import
naas
Copied!
Input your email and key words
1
your_email
=
"*********"
2
query
=
"data, automation, AI"
Copied!
Model
Use NewsAPI drivers to get data
1
table_news
=
newsapi
.
connect
().
get
(
q
=
query
)
2
3
# rename columns match the field required by Naas emailbuilder drivers
4
table_news
.
rename
(
columns
=
{
'title'
:
'text'
},
inplace
=
True
)
5
table_news
.
rename
(
columns
=
{
'link'
:
'row_link'
},
inplace
=
True
)
Copied!
Filter results
1
table_news_email
=
table_news
[:
10
]
2
table_news_email
=
table_news_email
[[
'text'
,
'row_link'
]]
3
table_news_email
Copied!
Format HTML content
1
links
=
[]
2
ht_str
=
"<ul>"
3
for
i
in
range
(
len
(
table_news_email
)):
4
val
=
"<li>"
+
"<a href="
+
'"'
+
table_news_email
[
'row_link'
][
i
]
+
'"'
+
">"
+
table_news_email
[
'text'
][
i
]
+
"</a>"
+
"</li>"
5
ht_str
=
ht_str
+
'\n'
+
val
6
ht_str
=
ht_str
+
"\n"
+
"</ul>"
Copied!
Fill the content of the mail
1
email_content
=
naas_drivers
.
emailbuilder
.
generate
(
2
display
=
'iframe'
,
3
title
=
f'🌏 NewsAPI brief'
,
4
subtitle
=
f'<b>Topics</b>:
{
query
}
'
,
5
table_1
=
ht_str
,
6
text
=
"Source: <a>https://newsapi.org/</a>"
7
)
Copied!
Output
Send email
1
naas
.
notification
.
send
(
email_to
=
your_email
,
subject
=
"News scheduled from Naas dev"
,
html
=
email_content
,
email_from
=
'
[email protected]
'
)
Copied!
Schedule everyday at 8am CET
Uncomment the line.
1
#naas.scheduler.add(recurrence="0 8 * * *")
Copied!
Display result
Previous
Get data
Next
Run sentiment analysis
Last modified
2mo ago
Copy link
Edit on GitHub
Contents
Input
Model
Output