https://anime-world.in/?trembed=0&trid=1930&trtype=2 此链接仅包含一个 iframe 标记,我想下载其中链接的视频。但是,src 属性将我带到一个无法访问的页面。我想知道如何下载视频。 我曾尝试访问源站点(错误 403),也曾尝试在网络面板中查找,但在那里找不到任何内容。谢谢您的帮助!
答案 0 :(得分:1)
您可以使用此脚本从 URL 下载视频:
import re
import requests
from bs4 import BeautifulSoup
url = "https://anime-world.in/?trembed=0&trid=1930&trtype=2"
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0",
"Referer": "https://anime-world.in/",
}
with requests.session() as s:
soup = BeautifulSoup(s.get(url, headers=headers).content, "html.parser")
url2 = soup.iframe["src"]
html_doc = s.get(url2, headers=headers).text
link = re.search(r'file:".*?(http[^",]+)', html_doc).group(1)
print(link)
with open("file.mp4", "wb") as f:
f.write(s.get(link, headers=headers, verify=False).content)
print("Done.")
打印:
https://6-yt5mQW3xieQHnfPa.server1cdn.xyz/link/AWI165B50FD/360/bb55f30227f8db11dcd19fef59fd6e5f/?sid=f3439234305d48ff7424333b2ca2de77
Done.
并用视频保存 file.mp4
(下载需要一点时间。)