Skip to content

Instantly share code, notes, and snippets.

@mtimkovich
Last active February 15, 2019 17:51
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 mtimkovich/853a2ac0b17def5188a75ca63e3f1024 to your computer and use it in GitHub Desktop.
Save mtimkovich/853a2ac0b17def5188a75ca63e3f1024 to your computer and use it in GitHub Desktop.
Make url requests from yaml file
#!/usr/bin/env python3
"""
Usage: curling.py input.yml
The input yaml file is structured like this. |method| is optional,
but must be lowercase.
url: url
method: get
params:
arg1: arg1
arg2: arg2
"""
import requests
import sys
import yaml
y = yaml.load(open(sys.argv[1]))
print(getattr(requests, y.get('method', 'get'))
(y['url'], data=y['params']).text, end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment