Skip to content

Instantly share code, notes, and snippets.

@developer-sdk
Created May 17, 2022 13:15
requests session
import requests
def basic_get(url):
response = requests.get(url)
print(response.text)
def session_get(url):
rs = requests.session()
rs.mount('http://', requests.adapters.HTTPAdapter(pool_connections=3, pool_maxsize=10, max_retries=3))
rs.mount('https://', requests.adapters.HTTPAdapter(pool_connections=3, pool_maxsize=10, max_retries=3))
rs.headers = {'Content-Type': 'application/json'}
response = rs.get(url)
print(response.text)
if __name__ == '__main__':
basic_get("http://www.naver.com")
session_get("http://www.naver.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment