An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
| import httplib | |
| import base64 | |
| try: | |
| import json | |
| except ImportError: | |
| import simplejson as json | |
| config = {"username": "your-sauce-username", | |
| "access-key": "your-sauce-api-key"} |
| # import config. | |
| # You can change the default config with `make cnf="config_special.env" build` | |
| cnf ?= config.env | |
| include $(cnf) | |
| export $(shell sed 's/=.*//' $(cnf)) | |
| # import deploy config | |
| # You can change the default deploy config with `make cnf="deploy_special.env" release` | |
| dpl ?= deploy.env | |
| include $(dpl) |
| import requests | |
| from requests.packages.urllib3.exceptions import InsecureRequestWarning | |
| requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | |
| URL = "https://www.somesitewithbadssl.com" | |
| headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0","Connection":"close","Accept-Language":"en-US,en;q=0.5","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Upgrade-Insecure-Requests":"1"} | |
| response = session.get(URL, headers=headers, timeout=15, verify=False) | |
| result = response.text | |
| print (result) |
| import asyncio | |
| loop = asyncio.get_event_loop() | |
| async def hello(): | |
| await asyncio.sleep(3) | |
| print('Hello!') | |
| if __name__ == '__main__': | |
| loop.run_until_complete(hello()) | |