Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

download files from website with cloudflare using Python

I am trying to download mp3 files, using python, from a website which has Cloud Flare. I know about 'cfscrape' module for python, but how do I use it to get download the file from the url.

like image 716
Haseeb Ahmad Avatar asked Sep 03 '26 12:09

Haseeb Ahmad


1 Answers

I got it.

import cfscrape

scraper = cfscrape.create_scraper()

url = 'the website url'
cfurl = scraper.get(url).content
name = url.split('/')[-1]

with open(name, 'wb') as f:
    f.write(cfurl)
like image 99
Haseeb Ahmad Avatar answered Sep 06 '26 03:09

Haseeb Ahmad