This commit is contained in:
Apocalypsor 2021-05-27 22:14:43 +08:00
parent 73b5319c60
commit dda8cd7485
2 changed files with 23 additions and 15 deletions

View File

@ -1,17 +1,19 @@
from .parser import rssParser, objParser
from .utils import postData, escapeAll, escapeText
from jinja2 import Template
from pymongo import MongoClient
import copy
import copyreg
import datetime
import hashlib
import time
import re
import yaml
from multiprocessing import Pool
import ssl
import copyreg
import copy
import os
import re
import ssl
import time
from multiprocessing import Pool
import yaml
from jinja2 import Template
from pymongo import MongoClient
from .parser import rssParser, objParser
from .utils import postData, escapeAll, escapeText
class FR2T:
@ -181,7 +183,9 @@ def handleRSS(rss, url, telegram, db, user_agent):
if send:
template = Template(rss["text"])
args = dict(**result, **content, rss_name=rss["name"], rss_url=rss["url"])
args = dict(
**result, **content, rss_name=rss["name"], rss_url=rss["url"]
)
escapeAll(telegram["parse_mode"], args)
text = template.render(args)

View File

@ -1,19 +1,23 @@
import feedparser
import json
import sys
import os
import sys
import feedparser
my_path = __file__
my_direc = os.path.dirname(__file__)
def parseUrl(url: str="https://github.com/Apocalypsor/Formatted-RSS-to-Telegram/commits/main.atom"):
def parseUrl(
url: str = "https://github.com/Apocalypsor/Formatted-RSS-to-Telegram/commits/main.atom",
):
d = feedparser.parse(url)["entries"]
file_name = url.replace("https://", "").replace("http://", "").replace("/", "_")
with open(os.path.join(my_direc, f"{file_name}.json"), "w", encoding="UTF-8") as t:
json.dump(d, t, indent=4, ensure_ascii=False)
if __name__ == "__main__":
if len(sys.argv) == 1:
parseUrl()