S
S
senks2022-02-10 19:31:09
Python
senks, 2022-02-10 19:31:09

Download pdf file from download link in python?

There is a link https://www.cian.ru/export/pdf/rent/flat/262482762/ . If you click on it, a page will open that will start downloading the PDF file and the page will instantly close. Is there a way to download this file to the right folder via python?
I tried to send a get request using the requests library, it gives only a 200 response, the file is not downloaded.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-02-10
@senks

I tried to send a get request using the requests library, it gives only a 200 response, the file is not downloaded.

Have you read the contents of the response and tried to write it to a file?
r = requests.get('https://www.cian.ru/export/pdf/rent/flat/262482762/')

with open('file.pdf', 'wb') as f:
    f.write(r.content)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question