Update test script
This commit is contained in:
parent
df267eda99
commit
c75da89032
3
.gitignore
vendored
3
.gitignore
vendored
@ -127,4 +127,5 @@ dmypy.json
|
|||||||
|
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
/.idea/
|
/.idea/
|
||||||
|
/test/*.json
|
@ -1 +0,0 @@
|
|||||||
[]
|
|
24
test/rss.py
24
test/rss.py
@ -1,8 +1,24 @@
|
|||||||
import feedparser
|
import feedparser
|
||||||
import json
|
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__
|
||||||
json.dump(d, t, indent=4, ensure_ascii=False)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user