python beautifulsoup load cookies download file from url code example

Example: python beautifulsoup load cookies download file from url

cookies = {'uid': '232323', 'pass': '31321231jh12j3hj213hj213hk',
           '__cfduid': 'kj123kj21kj31k23jkl21j321j3kl213kl21j3'}

try:
    read = requests.get(torrent_url, cookies=cookies)
    with open(save_as, 'wb') as w:
        for chunk in read.iter_content(chunk_size=512):
            if chunk:
                w.write(chunk)
            print(filename + ' downloaded successfully!!!')
except request.URLError as e:
    print("Error :%s" % e)