Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Python how to download protected files

python cookie

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 Onodera


    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 19 October 2014 - 04:10 PM

I would like to download a "token" protected file and to use my cookie file in order to avoid multiple re-login. The way i proceed is as follow

First of all, import the cookie

import requests, cookielib

cj = cookielib.MozillaCookieJar('cookies.txt')
r = requests.get(url, cookies=cj)

This is where i get a problem with, I must follow these steps in order to successfully download the desired file. (Everything in square brackets have to be replaced)

>> http://videoXXXXXXXX.fr/index.php?optio … &video_id=[VIDEO_ID]&load=1
Recover the cookie provided via "header set-cookie" 
>> http://videoXXXXXXXX.fr/index.php?optio … &video_id=[VIDEO_ID]
Recover the "order_id" in the sent back page [ORDER_ID]
>> http://videoXXXXXXXX.fr/index.php?optio … &order_id=[ORDER_ID]
Recover the response token: [Token]
>> http://videoXXXXXXXX.fr/index.php?optio … raw&token=[Token]&order_id=[ORDER_ID]
This step allow the activation of the cookie recovered in step 1 as well as to obtain the complete file
>> http://videoXXXXXXXX.fr/picture_[VIDEO_ID].png

But the truth is, I would like some help in order to do all that in "Python"

Thank you in advance for your time, as well as your help.


#2 BlackRabbit


    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 23 October 2014 - 07:49 PM

How good is your Python knowledge?


This link might be a kick starter to approach your problem

#3 Onodera


    CC Newcomer

  • Member
  • PipPip
  • 13 posts

Posted 24 October 2014 - 09:48 AM

I'm a beginner This programming language   thank you for your link :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download