Update wrapper.py

This commit is contained in:
akamhy authored and GitHub committed 2020-05-05 09:48:39 +05:30
1 parent 6705c04f38
commit 057c61d677
1 file changed
+2 -2
+2 -2
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
from datetime import datetime from datetime import datetime
from waybackpy.exceptions import TooManyArchivingRequests, ArchivingNotAllowed, PageNotSaved, ArchiveNotFound, UrlNotFound, UrlNotFound, InvalidUrl from waybackpy.exceptions import TooManyArchivingRequests, ArchivingNotAllowed, PageNotSaved, ArchiveNotFound, UrlNotFound, BadGateWay, InvalidUrl
try: try:
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
from urllib.error import HTTPError from urllib.error import HTTPError
@@ -44,7 +44,7 @@ def get(url,encoding=None,UA=default_UA):
hdr = { 'User-Agent' : '%s' % UA } hdr = { 'User-Agent' : '%s' % UA }
request_url = clean_url(url) request_url = clean_url(url)
req = Request(request_url, headers=hdr) req = Request(request_url, headers=hdr)
resp=urlopen(req) resp=urlopen(req) #nosec
if encoding is None: if encoding is None:
try: try:
encoding= resp.headers['content-type'].split('charset=')[-1] encoding= resp.headers['content-type'].split('charset=')[-1]