如何解决Google Colab Notebook Aparat.com视频下载器失败:连接超时正在重试
嗨,我想从video网站上使用Google colab笔记本下载aparat.com,所以我需要一些youtubedl之类的python模块或一些代码,因此我测试了wget
命令通过google colab来获取aparat视频下载链接(Colab页面为here)。但它不起作用:
!wget https://aspb2.cdn.asset.aparat.com/aparat-video/a2ba2346d4af486e4d542f5fc7bd96b915679753-480p.mp4
错误:
--2020-10-28 14:14:16-- https://aspb2.cdn.asset.aparat.com/aparat-video/a2ba2346d4af486e4d542f5fc7bd96b915679753-480p.mp4
Resolving aspb2.cdn.asset.aparat.com (aspb2.cdn.asset.aparat.com)... 91.229.46.35
Connecting to aspb2.cdn.asset.aparat.com (aspb2.cdn.asset.aparat.com)|91.229.46.35|:443... failed: Connection timed out.
Retrying.
--2020-10-28 14:14:49-- (try: 2) https://aspb2.cdn.asset.aparat.com/aparat-video/a2ba2346d4af486e4d542f5fc7bd96b915679753-480p.mp4
Connecting to aspb2.cdn.asset.aparat.com (aspb2.cdn.asset.aparat.com)|91.229.46.35|:443... failed: Connection timed out.
Retrying.
--2020-10-28 14:15:23-- (try: 3) https://aspb2.cdn.asset.aparat.com/aparat-video/a2ba2346d4af486e4d542f5fc7bd96b915679753-480p.mp4
Connecting to aspb2.cdn.asset.aparat.com (aspb2.cdn.asset.aparat.com)|91.229.46.35|:443..
these codes也不起作用:
!pip install tqdm
from tqdm import *
import requests
url = "https://aspb2.cdn.asset.aparat.com/aparat-video/a2ba2346d4af486e4d542f5fc7bd96b915679753-480p.mp4"
name = "video"
with requests.get(url,stream=True) as r:
r.raise_for_status()
with open(name,'wb') as f:
pbar = tqdm(total=int(r.headers['Content-Length']))
for chunk in r.iter_content(chunk_size=8192):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
pbar.update(len(chunk))
和此错误代码:
Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (4.41.1)
---------------------------------------------------------------------------
TimeoutError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/urllib3/connection.py in _new_conn(self)
158 conn = connection.create_connection(
--> 159 (self._dns_host,self.port),self.timeout,**extra_kw)
160
15 frames
TimeoutError: [Errno 110] Connection timed out
During handling of the above exception,another exception occurred:
NewConnectionError Traceback (most recent call last)
NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7ff04f337f60>: Failed to establish a new connection: [Errno 110] Connection timed out
During handling of the above exception,another exception occurred:
MaxRetryError Traceback (most recent call last)
MaxRetryError: HTTPSConnectionPool(host='aspb2.cdn.asset.aparat.com',port=443): Max retries exceeded with url: /aparat-video/a2ba2346d4af486e4d542f5fc7bd96b915679753-480p.mp4 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff04f337f60>: Failed to establish a new connection: [Errno 110] Connection timed out',))
During handling of the above exception,another exception occurred:
ConnectionError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/requests/adapters.py in send(self,request,stream,timeout,verify,cert,proxies)
514 raise SSLError(e,request=request)
515
--> 516 raise ConnectionError(e,request=request)
517
518 except ClosedPoolError as e:
ConnectionError: HTTPSConnectionPool(host='aspb2.cdn.asset.aparat.com',))
似乎aparat网站阻止了Google colab IP,也许可以通过代理或...解决。
因此,如果可能,建议一些解决方法。
谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。