-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhook.py
33 lines (25 loc) · 978 Bytes
/
webhook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from discord_webhook import DiscordEmbed, DiscordWebhook
import requests
from time import sleep
import sys
import news # not a pip library, file that gets the articles, etc
# get what webhooks to send it too from the config file
# will warn if you do not have the config, and exit
try:
from config import urls
except:
sys.exit("Config was not loaded")
# get the articles
article = news.run()
webHook = DiscordWebhook(url=urls)
embed = DiscordEmbed(title='Finance News:', color='7289DA')
embed.set_footer(text='Articles were scraped from Google Finance • This is not financial advice\nStar us on Github! • https://github.com/Prasantacharya/Finance-News-Webhook')
for page in article:
embedTitle = ', '.join(page["names"]) + " news:"
embedText = f"[**{page['title']}**]({page['link']})\n{page['text']}"
embed.add_embed_field(
name=embedTitle,
value=embedText,
inline=False)
webHook.add_embed(embed)
resp = webHook.execute()