06-03-2019, Saat: 02:24
Arkadaşlar bir döngüde 10 tane dosya indirmek istiyorum yapamadım şunu bir türlü
Kod:
import requests
import re
downfile_id = 10
def get_filename_from_cd(cd):
if not cd:
return None
fname = re.findall('filename=(.+)', cd)
if len(fname) == 0:
return None
return fname[0]
for i in range(10):
url = 'https://community.mybb.com/attachment.php?aid='
r = requests.get(url + str(downfile_id), allow_redirects=True)
filename = get_filename_from_cd(r.headers.get('content-disposition'))
open(filename, 'wb').write(r.content)
downfile_id +=1