我试图从Tik-Tok下载一段视频,使用它的视频ID link
在浏览器中,上面的链接将我重定向到下面的URL 当我尝试使用请求.get,我不明白响应历史记录,意味着请求认为没有重定向。在
import urllib.request
import requests
post_url = "https://api2.musical.ly/aweme/v1/play/?video_id=v09044a20000beeff4c108gs7sflfdug"
vid_url = "http://v16.muscdn.com/e8cee4f83f4c598a9d13ba6e4f7cead2/5d058940/video/tos/maliva/tos-maliva-v-0068/e5a1ab74d0b54f97b3578924a428e58d/?rc=amdvdnY7NDdpaDMzNTczM0ApQHRAbzg5ODozOjM0NDY0Ozg5PDNAKXUpQGczdSlAZjN2KUBmaGhkbGRlemhoZGY2NUByY2M0ZC1gY2JfLS1eMTZzczVvI28jQjItLzEuLi0tLS4uLi0uL2k6YjBwIzphLXEjOmAtbyNqdFxtK2IranQ6IzAuXg%3D%3D"
response = requests.get(post_url)
if response.history:
print("Request was redirected")
for resp in response.history:
print(resp.status_code, resp.url)
print("Final destination:")
print(response.status_code, response.url)
else:
print("Request was not redirected")
这将导致“请求未重定向”
我正在尝试从response
获取视频url。在
您应该使用标题,请尝试替换此项:
有了这个:
^{pr2}$希望这有帮助!在
我可以下载视频你所要做的就是请求视频的网址,然后把视频作为一个文件来写。在
我已经检查过了。希望你得到了你想要的
相关问题 更多 >
编程相关推荐