-
-
Save twhite96/5d7c0453e6f98940d397721ef3f39106 to your computer and use it in GitHub Desktop.
RSS Feed Generator for Blog example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding=utf8 | |
import feedparser | |
import typer | |
from typing import Optional | |
import sys | |
import datetime | |
import urllib | |
import pprint | |
import datetime | |
import json | |
# We'll need to instantiate the Typer class so we can | |
# work with it later when we need to get input | |
# from the command line | |
app = typer.Typer() | |
# Here I created a function where I pass a default parameter | |
# and assign that parameter to the app variable I created above the function | |
# I have not run this yet so not sure of any scope issues | |
def main(url: str = typer.Option(...,prompt="Please enter the url you'd like to parse")): | |
""" | |
This is where I'll place morst of | |
the business logic for this script | |
""" | |
app.echo(f"{url}") | |
fp = feedparser.parse(url) | |
fp['feed']['title'] | |
print(fp) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment