Update test script
This commit is contained in:
parent
df267eda99
commit
c75da89032
1
.gitignore
vendored
1
.gitignore
vendored
@ -128,3 +128,4 @@ dmypy.json
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
/.idea/
|
||||
/test/*.json
|
@ -1 +0,0 @@
|
||||
[]
|
20
test/rss.py
20
test/rss.py
@ -1,8 +1,24 @@
|
||||
import feedparser
|
||||
import json
|
||||
import sys
|
||||
import os
|
||||
|
||||
url = "https://rsshub.app/bilibili/user/bangumi/2975898"
|
||||
|
||||
my_path = __file__
|
||||
my_direc = os.path.dirname(__file__)
|
||||
|
||||
def parseUrl(url: str="https://github.com/Apocalypsor/Formatted-RSS-to-Telegram/commits/main.atom"):
|
||||
d = feedparser.parse(url)["entries"]
|
||||
|
||||
with open("example.json", "w") as t:
|
||||
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()
|
||||
elif len(sys.argv) == 2:
|
||||
parseUrl(sys.argv[1])
|
||||
else:
|
||||
for u in sys.argv[1:]:
|
||||
parseUrl(u)
|
||||
|
Loading…
Reference in New Issue
Block a user