mirror of
https://github.com/tcsenpai/mysides.git
synced 2025-06-02 17:20:05 +00:00
replaced euobserver with its rss feed and added generic rss feed support
This commit is contained in:
parent
35969b087d
commit
92f26cb193
16
.env.example
16
.env.example
@ -1,15 +1,5 @@
|
||||
PPLX_API_KEY="your perplexity ai key"
|
||||
MODEL="pplx-7b-chat"
|
||||
NEWS="world-news"
|
||||
POSSIBLE_NEWS_VALUES= '
|
||||
"world-news",
|
||||
"us-news",
|
||||
"politics",
|
||||
"sports",
|
||||
"entertainment",
|
||||
"business",
|
||||
"science",
|
||||
"ap-fact-check",
|
||||
"oddities",
|
||||
"health"
|
||||
'
|
||||
ENABLED_RSS="
|
||||
'https://xml.euobserver.com/rss.xml',
|
||||
"
|
@ -13,7 +13,7 @@ MySides is a personal tool designed to scrape news from various sources. Please
|
||||
## Built-in sites
|
||||
|
||||
[x] APNews (world news)
|
||||
[x] EuObserver (rss feed)
|
||||
[x] Any RSS feed (by adding it to the .env file)
|
||||
|
||||
## Work In Progress
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,13 +0,0 @@
|
||||
import feedparser
|
||||
|
||||
def fetchAndDigest():
|
||||
links = []
|
||||
feed = feedparser.parse("https://xml.euobserver.com/rss.xml")
|
||||
for entry in feed.entries:
|
||||
|
||||
article_title = entry.title
|
||||
article_link = entry.link
|
||||
links.append([article_title, article_link])
|
||||
|
||||
print("[+] Total news: " + str(len(links)))
|
||||
return links
|
@ -1,9 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
pip install -r requirements.txt
|
||||
mkdir news
|
||||
cp .env.example .env
|
||||
echo "You should now open your .env file and insert your Perplexity API Key."
|
||||
echo "You can get one at: https://www.perplexity.ai/settings/api"
|
||||
echo "Then, launch main.py and wait for it to finish."
|
||||
echo "allsides.html contains an overview of all the news."
|
||||
|
8
main.py
8
main.py
@ -3,7 +3,7 @@ from dotenv import load_dotenv
|
||||
|
||||
# Our modules
|
||||
import apnews
|
||||
import euobserver
|
||||
import rss
|
||||
import summarizer
|
||||
|
||||
load_dotenv()
|
||||
@ -42,9 +42,13 @@ def transform_links(links):
|
||||
def extract_data():
|
||||
links = []
|
||||
|
||||
# Add your rss link to the .env file
|
||||
rss_links = os.getenv("ENABLED_RSS").split(",")
|
||||
links.extend(rss.fetchAndDigest(rss_links))
|
||||
|
||||
# Plug in your module here (links.extend(your_module.fetchAndDigest())
|
||||
# TODO Programmatically scan and import modules
|
||||
links.extend(apnews.fetchAndDigest())
|
||||
links.extend(euobserver.fetchAndDigest())
|
||||
|
||||
print("[+] Total news: " + str(len(links)))
|
||||
datas = transform_links(links)
|
||||
|
21
rss.py
Normal file
21
rss.py
Normal file
@ -0,0 +1,21 @@
|
||||
import feedparser
|
||||
|
||||
def fetchAndDigest(rss_feeds):
|
||||
links = []
|
||||
for rss_url in rss_feeds:
|
||||
rss_url = rss_url.replace("'", "")
|
||||
print("[+] Fetching RSS feed: " + rss_url)
|
||||
links.extend(fetchAndDigest_subroutine(rss_url))
|
||||
return links
|
||||
|
||||
def fetchAndDigest_subroutine(rss_url):
|
||||
links = []
|
||||
feed = feedparser.parse(rss_url)
|
||||
for entry in feed.entries:
|
||||
|
||||
article_title = entry.title
|
||||
article_link = entry.link
|
||||
links.append([article_title, article_link])
|
||||
|
||||
print("[+] Total news: " + str(len(links)))
|
||||
return links
|
Loading…
x
Reference in New Issue
Block a user