Snippets Collections
import asyncio

import httpx


async def main():
	async with httpx.AsyncClient() as client:
		resp = await client.get("https://python.org")
        http_text = await resp.text()
		print(http_text)


loop = asyncio.get_event_loop()
loop.run_until_complete(main())
import json
import os
import requests
from models import Asset

apikey = os.environ.get('API_KEY')

headers = {
    'X-CMC_PRO_API_KEY': apikey,
    'Accepts': 'application/json'
}

params = {
    'start': '1',
    'limit': '5',
    'convert': 'USD'
}


def getTokePrice(symbol):
    url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'

    json = requests.get(url, params=params, headers=headers).json()
    coins = json['data']
import json
import requests

apikey = '43979f1b-f353-4842-ad8a-ecb2735f3b71'

headers = {
    'X-CMC_PRO_API_KEY' : apikey,
    'Accepts' : 'application/json'
}

params = {
    'start' : '1',
    'limit' : '5',
    'convert' : 'USD'
}

url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'

json = requests.get(url, params=params, headers=headers).json()

coins = json['data']

for coin in coins:
    if coin['symbol'] == 'BTC':
        print(coin['symbol'], coin['quote']['USD']['price'])
import json
import requests

apikey = '43979f1b-f353-4842-ad8a-ecb2735f3b71'

headers = {
    'X-CMC_PRO_API_KEY' : apikey,
    'Accepts' : 'application/json'
}

params = {
    'start' : '1',
    'limit' : '5',
    'convert' : 'USD'
}

url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest'

json = requests.get(url, params=params, headers=headers).json()

coins = json['data']

for coin in coins:
    print(coin['symbol'], coin['quote']['USD']['price'])
import json
import requests

eth = requests.get(
    "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd")

print(eth.json()["ethereum"]["usd"])
import aiohttp
import asyncio
 
 
async def fetch(client):
    async with client.get("https://python.org") as resp:
        assert resp.status == 200
        return await resp.text()
 
 
async def main():
    async with aiohttp.ClientSession() as client:
        html = await fetch(client)
        print(html)
 
 
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
import aiohttp
import asyncio


async def fetch(client):
    async with client.get("https://python.org") as resp:
        assert resp.status == 200
        return await resp.text()


async def main():
    async with aiohttp.ClientSession() as client:
        html = await fetch(client)
        print(html)


loop = asyncio.get_event_loop()
loop.run_until_complete(main())
star

Thu Mar 17 2022 17:49:21 GMT+0000 (UTC) https://www.youtube.com/watch?v=iIGNhBcj4zs

#python #get #requests
star

Thu Mar 17 2022 17:43:19 GMT+0000 (UTC) https://www.youtube.com/watch?v=iIGNhBcj4zs

#python #get #requests
star

Thu Mar 17 2022 14:51:14 GMT+0000 (UTC) https://realpython.com/python-requests/

#python #get #requests
star

Sun Jan 30 2022 16:39:51 GMT+0000 (UTC)

#python #requests

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension