Answer the question
In order to leave comments, you need to log in
How to get headers via session.post without downloading the whole file?
There is a file storage. They can be obtained from a link like 'site_name/id_file'. I do it like this:
import requests
session = requests.Session()
session.post('site_name/авторизация', {
'remember': 1,
})
for num in range(1, 100):
link = 'site_name/' + str(num)
res = session.post(link)
if res.status_code == 200:
file_name = res.headers['Content-Disposition']
fd = open(file_name, 'wb')
fd.write(res.content)
fd.close()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question