i try this code to download many pdf files:
import requests
for i in range(1, 30):
r = requests.get('http://www.setpp.kemenkeu.go.id/risalah/ambilFileDariDisk/'+str(i), allow_redirects=True)
open('file-risalah.pdf', 'wb').write(r.content)
but it only outputs a single pdf file. how to download each pdf file so that it can output as many file as in the iteration? i tied:
import requests
for i in range(1, 30):
r = requests.get('http://www.setpp.kemenkeu.go.id/risalah/ambilFileDariDisk/'+str(i), allow_redirects=True)
open('file-risalah'+str[i]+'.pdf', 'wb').write(r.content)
but its error
str[i]is not the correct syntax though. You used the correct syntax inrequests.get('...ambilFileDariDisk/'+str(i), ...)