Skip to content

Instantly share code, notes, and snippets.

@sodonnell
Last active December 4, 2019 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sodonnell/2ab75ddf2ec87d57cc3ca55e3c075451 to your computer and use it in GitHub Desktop.
Save sodonnell/2ab75ddf2ec87d57cc3ca55e3c075451 to your computer and use it in GitHub Desktop.
Basic YAML Parsing in Python
language: python
python: 3.6
script:
- python3 feed.py -u https://phys.org/rss-feed/
- python3 feed.py -u https://hackaday.com/blog/feed/
- python3 feed.py -u https://www.wired.com/feed/rss
#!/usr/bin/env python3
import yaml
# "unsafe" load of untrusted data
#mydata = yaml.load(open("test.yml"), Loader=yaml.FullLoader)
# "safe" load of untrusted data
mydata = yaml.safe_load(open("test.yml"))
# print the entire dictionary
print(mydata)
# print a specific dictionary node
print(mydata['language'])
# print a specific dictionary sub-node
print(mydata['script'][2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment