Update test script

This commit is contained in:
Apocalypsor 2021-05-27 18:44:05 +08:00
parent df267eda99
commit c75da89032
3 changed files with 22 additions and 6 deletions

1
.gitignore vendored
View File

@ -128,3 +128,4 @@ dmypy.json
# Pyre type checker
.pyre/
/.idea/
/test/*.json

View File

@ -1 +0,0 @@
[]

View File

@ -1,8 +1,24 @@
import feedparser
import json
import sys
import os
url = "https://rsshub.app/bilibili/user/bangumi/2975898"
d = feedparser.parse(url)["entries"]
with open("example.json", "w") as t:
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"]
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)