detecet python version whith sys.version_info (#9)

This commit is contained in:
Akash 2020-06-26 15:48:01 +05:30 committed by GitHub
parent f015c3f4f3
commit f881705d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,21 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys
import json import json
from datetime import datetime from datetime import datetime
from waybackpy.exceptions import TooManyArchivingRequests, ArchivingNotAllowed, PageNotSaved, ArchiveNotFound, UrlNotFound, BadGateWay, InvalidUrl, WaybackUnavailable from waybackpy.exceptions import TooManyArchivingRequests, ArchivingNotAllowed, PageNotSaved, ArchiveNotFound, UrlNotFound, BadGateWay, InvalidUrl, WaybackUnavailable
try:
version = (3, 0)
cur_version = sys.version_info
if cur_version >= version: # If the python ver >= 3
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError from urllib.error import HTTPError, URLError
except ImportError: else: # For python2.x
from urllib2 import Request, urlopen, HTTPError, URLError from urllib2 import Request, urlopen, HTTPError, URLError
default_UA = "waybackpy python package ; ( https://github.com/akamhy/waybackpy )"
default_UA = "waybackpy python package"
def url_check(url): def url_check(url):
if "." not in url: if "." not in url: