Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Extension
#1
Hey! Friends.
Problem: How to get extension of the file from url or else anything using request or any module?
Another Problem: Can I Use To Split Files In Python And Download Them Using Threading?
Here Is The Code:
import requests
import threading
def download(url):
    r = requests.get(url, allow_redirects=True)

    response = requests.get(url, stream = True)

    text_file = open("data.html","wb")
    for chunk in response.iter_content(chunk_size=1024):
        text_file.write(chunk)
    #writing one chunk at a time to text file


    text_file.close()
t = threading.Thread(target=download,args=('https://youtu.be/zcywDfl7vJs',))
t.start()
Reply


Messages In This Thread
Getting Extension - by Harshil - Aug-22-2020, 06:35 AM
RE: Getting Extension - by ndc85430 - Aug-22-2020, 07:11 AM
RE: Getting Extension - by Harshil - Aug-22-2020, 07:12 AM
RE: Getting Extension - by ndc85430 - Aug-22-2020, 07:14 AM
RE: Getting Extension - by Harshil - Aug-22-2020, 07:20 AM
RE: Getting Extension - by ndc85430 - Aug-22-2020, 07:20 AM
RE: Getting Extension - by Harshil - Aug-22-2020, 07:24 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020