Python Notes: https harder demo

  1. The information presented here is intended for educational use.
  2. The information presented here is provided free of charge, as-is, with no warranty of any kind.
  3. Edit: 2023-09-24

https_harder_demo

#!/bin/python3
'''
============================================================ title : https_harder_demo_100.py author : Neil Rieck created : 2023-07-07
purpose : connect to an older https site history :
ver who when what 100 NSR 230707 1. original effort ============================================================
'''
import requests import urllib3 import sys def main(): print(f"-i-program: {sys.argv[0]}") # # does get http work? # try: print("*"*40, " http.get()") sess = requests.Session() # maintains cookies, etc. r = sess.get('http://kawc96.on.bell.ca', timeout=5) print(r.status_code) print(r.text) except Exception as e: print(f"-e-error: {e}") print("*"*40, " stop http") # # does get https work? # try: print("*"*40, " https.get()") requests.packages.urllib3.disable_warnings() requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL' try: requests.packages.urllib3.contrib.pyopenssl.util.ssl_.DEFAULT_CIPHERS += ':HIGH:!DH:!aNULL' except AttributeError: # no pyopenssl support used / needed / available pass sess = requests.Session() r = sess.get('https://kawc96.on.bell.ca', timeout=5) print(r.status_code) print(r.text) except Exception as e: print(f"-e-error: {e}") print("*"*40, " stop https") if __name__ == "__main__": main() # this is the end

Links


 Back to Home
 Neil Rieck
 Waterloo, Ontario, Canada.