Last active
February 15, 2019 17:51
-
-
Save mtimkovich/853a2ac0b17def5188a75ca63e3f1024 to your computer and use it in GitHub Desktop.
Make url requests from yaml file
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 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