def urlopen(url): from urllib.request import urlopen as impl import ssl ctx_no_secure = ssl.create_default_context() ctx_no_secure.set_ciphers('HIGH:!DH:!aNULL') ctx_no_secure.check_hostname = False ctx_no_secure.verify_mode = ssl.CERT_NONE return impl(url, context=ctx_no_secure)
def download(YEAR, MONTH, destdir): logging.info(f"requesting {YEAR}-{MONTH}") PARAMS_ = PARAMS.format(YEAR, MONTH) filename = os.path.join(destdir, f"{YEAR}{MONTH}.zip") with open(filename, "wb") as fp: with impl(URL, PARAMS_.encode("utf-8")) as res: logging.info(f"status={res.status}") fp.write(res.read()) return filename
def urlopen(url, data): return impl(url, data.encode('utf-8'), context=ctx_no_secure)
def urlopen(url, data): from urllib.request import urlopen as impl return impl(url, data.encode('utf-8'))
def urlopen(url, data): return impl(url, data.encode('utf-8'))
def send_request_get_response_with_data(self): return impl(self.request_url_to_download_flights_record_from_bts, self.params_to_form_downloaded_data.encode('utf-8'), context=ctx_no_secure)