Question

I need to get a YAML file from the web and parse it using PyYAMl, but i can't seem to find a way to do it.

import urllib
import yaml
fileToBeParsed = urllib.urlopen("http://website.com/file.yml")
pythonObject = yaml.open(fileToBeParsed)
print pythonObject

The error produced when runing this is: AttributeError: 'module' object has no attribute 'open'

If it helps, I am using python 2. Sorry if this is a silly question.

Was it helpful?

Solution

I believe you want yaml.load(fileToBeParsed) and I would suggest looking at urllib2.urlopen if not the requests module.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top