-1

I wrote a small script can get a link and download it. Now I want to add Resume's property to my script. This script written in python 3 and requests library.

Below is main download section of my code:

class downloader(Thread):
    def __init__(self,url,filename):
        super().__init__()
        self.filename=filename
        self.url=url
    def run(self):
        self.request()
    def request(self):
        headers = {'user-agent': 'pydownloader/0.0.1'}
        r=get(self.url,headers=headers,timeout=10,stream=True)
        with open(self.filename, 'wb') as fd:
            for chunk in r.iter_content(chunk_size=128):
                fd.write(chunk)     
        _exit(1)
faruk13
  • 1,276
  • 1
  • 16
  • 23
mohamadreza ch
  • 311
  • 4
  • 13

1 Answers1

0

I implemented that via Range in http header

example:

Range:12343- ===> from 12343 to end

headers = {'user-agent': 'pydownloader/0.0.1','Range':'bytes=12343-'}

mohamadreza ch
  • 311
  • 4
  • 13