2024-05-19 02:13:48 发布
网友
我试图用python构建一个scraper,只想下载podcast的新剧集。问题是我不知道文件名,直到文件下载后。有没有办法在下载前获取文件名?在
def download(path, fileName): if(not os.path.exists(fileName)): wget.download(path)
我猜podcast的url会把你重定向到另一个url。然后可以使用requests来获得最终的url
requests
import requests final_url = requests.head(url_to_podcast, allow_redirects=True).url
然后从最终的url获取文件名
我猜podcast的url会把你重定向到另一个url。然后可以使用
requests
来获得最终的url然后从最终的url获取文件名
^{pr2}$相关问题 更多 >
编程相关推荐