def url_request(self, url, file_path, proxy_url=None):
try:
urllib_request.urlretrieve(url, file_path)
print(file_path)
except HTTPError as e:
print(e.code)
if proxy_url is not None:
print("Trying proxy URL")
url = proxy_url
await self.url_request(url, file_path)
else:
raise e
except UnicodeEncodeError:
# Special retry logic for IDN domains
url = "http://" + url.replace("http://", "").encode("idna").decode("utf-8")
await self.url_request(url, file_path)
评论列表
文章目录