M
M
m1kz2021-07-01 10:24:39
Python
m1kz, 2021-07-01 10:24:39

How to download music?

It downloads from the browser, not in python, how to solve it?

import requests


with open('111.mp3', 'wb') as f:
    f.write(requests.get('https ://z2.fm/download/32179540').content)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vindicar, 2021-07-01
@Vindicar

What is downloading in python?
In general, this site can check and filter out bots, such as your script.
How to bypass this check depends on how the check is done. In simple cases, the correct set of HTTP headers (for example, the same as the browser sends) will suffice. In complex JS there is a check, and you will have to connect a browser emulator like selenium.

D
Deleting Account, 2021-07-01
@Andriy_Kosmenyuk

https://z2.fm/ajax/inc/32179540 , and look in the console what the browser does with this request, what headers, where it receives cookies from, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question