简体   繁体   中英

Request and download a zip file from Open Subtitles in Python

Hey I'm trying to download subtitles using a python script Let's take this movie subtitles for example if you try and click one of the numbers of downloads for a specific subtitle, it will instantly download it as a zip file. But if you open the href link in a different tab it won't download you have to click it. How is it possible to download it using requests or urllib?

This is what I have at the moment:

r = requests.get(link)
z = zipfile.ZipFile(io.BytesIO(r.content))
z.extractall(os.getcwd() + '\\movies\\' + movie_name1 + ".zip")

The download link for opensubtitles is "https://www.opensubtitles.org/en/download/vrf-108d030f/sub/{site_id}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM