|
| 1 | +import argparse |
| 2 | + |
| 3 | + |
| 4 | +"""Automates posting to social channels and tutorials page on |
| 5 | +fullstackpython.com. |
| 6 | +
|
| 7 | +Arguments: |
| 8 | +
|
| 9 | +-c, --channel which channel to post to, options are "all", "twitter", |
| 10 | + "facebook", "tutorials" |
| 11 | +
|
| 12 | +-s, --subject custom subject line for the posting, otherwise <h1> |
| 13 | + element's content will be used |
| 14 | +
|
| 15 | +-t, --tags tags for tutorials page |
| 16 | +
|
| 17 | +
|
| 18 | +Examples: |
| 19 | +
|
| 20 | +1. Post URL to all channels with the default title found within the page's |
| 21 | + <h1> and tagged with any keywords that match between the page content |
| 22 | + and the table of contents map. |
| 23 | +
|
| 24 | + python post.py https://www.fullstackpython.com/django.html |
| 25 | +
|
| 26 | +
|
| 27 | +2. Post URL to all channels with the default title found within the page's |
| 28 | + <h1> and tagged "git" and "source control". |
| 29 | +
|
| 30 | + python post.py https://www.fullstackpython.com/git.html "git, source control" |
| 31 | +
|
| 32 | +
|
| 33 | +3. Post URL to all channels with a custom description of "Newest Mapbox |
| 34 | + tutorial is live!" and tagged "django", "web development" and |
| 35 | + "web frameworks". |
| 36 | +
|
| 37 | + python post.py https://www.fullstackpython.com/blog/maps-django-web-applications-projects-mapbox.html "django, web development, web frameworks" -d "Newest Mapbox tutorial is live!" |
| 38 | +
|
| 39 | +
|
| 40 | +4. Post URL only to Twitter with a custom description of "An overview of relational databases for Python." |
| 41 | +
|
| 42 | + python post.py https://www.fullstackpython.com/databases.html "postgresql, mysql" -d "An overview of relational databases for Python." -c twitter |
| 43 | +""" |
| 44 | + |
| 45 | +parser = argparse.ArgumentParser(description='Post a tutorial.') |
| 46 | +parser.add_argument('url', metavar='1', type=str, nargs='?', |
| 47 | + help='URL for the tutorial to post') |
| 48 | +parser.add_argument("-c", "--channel", help="channel to post tutorial to") |
| 49 | + |
| 50 | + |
| 51 | +args = parser.parse_args() |
| 52 | +print(args.url) |
| 53 | +print(args.channel) |
0 commit comments